Widget:Google Books: Difference between revisions
No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
To use this widget, add the following code to your wiki page: | To use this widget, add the following code to your wiki page: | ||
</noinclude> | </noinclude> | ||
<includeonly> | <includeonly> | ||
<!-- | <!-- This is important: Place the viewer exactly where we want it --> | ||
<div | <div style="position:relative; width:<!--{$width|escape:'html'|default:'600'}-->px; height:<!--{$height|escape:'html'|default:'500'}-->px; margin:1em 0;"> | ||
<script type="text/javascript" src="https://books.google.com/books/previewlib.js"></script> | |||
<script type="text/javascript"> | |||
<script type="text/javascript" src="https://books.google.com/books/ | /* <![CDATA[ */ | ||
(function() { | |||
var bId = "<!--{$id|escape:'html'}-->"; | |||
<script type="text/javascript"> | var width = <!--{$width|escape:'html'|default:'600'}-->; | ||
/* <![CDATA[ */ | var height = <!--{$height|escape:'html'|default:'500'}-->; | ||
// Create an inline placeholder | |||
function | document.write('<div id="gbPreviewContainer_' + bId + '" style="width:' + width + 'px; height:' + height + 'px;"></div>'); | ||
// Insert the viewer at the placeholder location | |||
} | function insertViewer() { | ||
if (typeof GBS_insertEmbeddedViewer === 'function') { | |||
GBS_insertEmbeddedViewer(bId, width, height); | |||
/* ]]> */ | } else { | ||
</script> | // Retry if API not loaded yet | ||
setTimeout(insertViewer, 100); | |||
} | |||
} | |||
insertViewer(); | |||
})(); | |||
/* ]]> */ | |||
</script> | |||
</div> | |||
</includeonly> | </includeonly> |
Revision as of 15:29, 10 March 2025
This widget allows you to embed Google Books on your wiki page. Originally created by Arv and adapted by FrancisFranck.
Using this widget
To use this widget, add the following code to your wiki page: