Created
December 10, 2013 19:18
-
-
Save javajack/7896449 to your computer and use it in GitHub Desktop.
A JQuery Plugin for Google Doc Viewer Iframe Embeding http://jsfiddle.net/javajack/4s8bn/embedded/result/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* jQuery.gdocViewer - Embed linked documents using Google Docs Viewer | |
* Licensed under MIT license. | |
* Date: 2011/01/16 | |
* | |
* @author Jawish Hameed | |
* @version 1.0 | |
*/ | |
(function($){ | |
$.fn.gdocsViewer = function(options) { | |
var settings = { | |
width : '600', | |
height : '700' | |
}; | |
if (options) { | |
$.extend(settings, options); | |
} | |
return this.each(function() { | |
var file = $(this).attr('href'); | |
var ext = file.substring(file.lastIndexOf('.') + 1); | |
if (/^(tiff|pdf|ppt|pps|doc|docx)$/.test(ext)) { | |
$(this).after(function () { | |
var id = $(this).attr('id'); | |
var gdvId = (typeof id !== 'undefined' && id !== false) ? id + '-gdocsviewer' : ''; | |
return '<div id="' + gdvId + '" class="gdocsviewer"><iframe src="http://docs.google.com/viewer?embedded=true&url=' + encodeURIComponent(file) + '" width="' + settings.width + '" height="' + settings.height + '" style="border: none;margin : 0 auto; display : block;"></iframe></div>'; | |
}) | |
} | |
}); | |
}; | |
})( jQuery ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$('a.embed').gdocsViewer({width: 740, height: 742}); | |
$('#embedURL').gdocsViewer(); | |
}); | |
<a href="www.snee.com/xml/xslt/sample.doc" class="embed" style="text-align : center; display : block;">PDF test georgetown.edu</a> |
ghost
commented
Nov 26, 2019
@javajack is it possible to remove pop-out option in google document viewer ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment