ninjawords.com <div dir="ltr" style="text-align: left;" trbidi="on"><br /><div class="" style="text-align: left;"><br /></div><br /><div style="text-align: center;"><br />Ninja Word<br /></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><div class=""><br /><script src="http://code.jquery.com/jquery-1.10.1.min.js"></script><br /><script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script><br /><script type="text/javascript"><br />/*jslint white: true, indent: 2, onevar: false, browser: true, undef: true, nomen: false, eqeqeq: true, plusplus: false, bitwise: true, regexp: true, strict: false, newcap: true, immed: true */<br />/*global window, console, jQuery, setTimeout */<br /><br />/*<br /> Plugin: iframe autoheight jQuery Plugin<br /> Version: 1.9.3<br /> Author and Contributors<br /> ========================================<br /> NATHAN SMITH (http://sonspring.com/)<br /> Jesse House (https://github.com/house9)<br /> aaron manela (https://github.com/aaronmanela)<br /> Hideki Abe (https://github.com/hideki-a)<br /> Patrick Clark (https://github.com/hellopat)<br /> ChristineP2 (https://github.com/ChristineP2)<br /> Mmjavellana (https://github.com/Mmjavellana)<br /> yiqing-95 (https://github.com/yiqing-95)<br /> jcaspian (https://github.com/jcaspian)<br /> adamjgray (https://github.com/adamjgray)<br /> Jens Bissinger (https://github.com/dpree)<br /><br /> File: jquery.iframe-auto-height.plugin.js<br /> Remarks: original code from http://sonspring.com/journal/jquery-iframe-sizing<br /> Description: when the page loads set the height of an iframe based on the height of its contents<br /> see README: http://github.com/house9/jquery-iframe-auto-height<br /><br />*/<br />(function ($) {<br /> $.fn.iframeAutoHeight = function (spec) {<br /><br /> var undef;<br /> if ($.browser === undef) {<br /> var message = [];<br /> message.push("WARNING: you appear to be using a newer version of jquery which does not support the $.browser variable.");<br /> message.push("The jQuery iframe auto height plugin relies heavly on the $.browser features.");<br /> message.push("Install jquery-browser: https://raw.github.com/house9/jquery-iframe-auto-height/master/release/jquery.browser.js");<br /> alert(message.join("\n"));<br /> return $;<br /> }<br /><br /> // set default option values<br /> var options = $.extend({<br /> heightOffset: 0,<br /> minHeight: 0,<br /> callback: function (newHeight) {},<br /> animate: false,<br /> debug: false,<br /> diagnostics: false, // used for development only<br /> resetToMinHeight: false,<br /> triggerFunctions: [],<br /> heightCalculationOverrides: []<br /> }, spec);<br /><br /> // logging<br /> function debug(message) {<br /> if (options.debug && options.debug === true && window.console) {<br /> console.log(message);<br /> }<br /> }<br /><br /> // not used by production code<br /> function showDiagnostics(iframe, calledFrom) {<br /> debug("Diagnostics from '" + calledFrom + "'");<br /> try {<br /> debug(" " + $(iframe, window.top.document).contents().find('body')[0].scrollHeight + " for ...find('body')[0].scrollHeight");<br /> debug(" " + $(iframe.contentWindow.document).height() + " for ...contentWindow.document).height()");<br /> debug(" " + $(iframe.contentWindow.document.body).height() + " for ...contentWindow.document.body).height()");<br /> } catch (ex) {<br /> // ie fails when called during for each, ok later on<br /> // probably not an issue if called in a document ready block<br /> debug(" unable to check in this state");<br /> }<br /> debug("End diagnostics -> results vary by browser and when diagnostics are requested");<br /> }<br /><br /> // show all option values<br /> debug(options);<br /><br /> // ******************************************************<br /> // iterate over the matched elements passed to the plugin ; return will make it chainable<br /> return this.each(function () {<br /><br /> // ******************************************************<br /> // http://api.jquery.com/jQuery.browser/<br /> var strategyKeys = ['webkit', 'mozilla', 'msie', 'opera'];<br /> var strategies = [];<br /> strategies['default'] = function (iframe, $iframeBody, options, browser) {<br /> // NOTE: this is how the plugin determines the iframe height, override if you need custom<br /> return $iframeBody[0].scrollHeight + options.heightOffset;<br /> };<br /><br /> jQuery.each(strategyKeys, function (index, value) {<br /> // use the default strategy for all browsers, can be overridden if desired<br /> strategies[value] = strategies['default'];<br /> });<br /><br /> // override strategies if registered in options<br /> jQuery.each(options.heightCalculationOverrides, function (index, value) {<br /> strategies[value.browser] = value.calculation;<br /> });<br /><br /> function findStrategy(browser) {<br /> var strategy = null;<br /><br /> jQuery.each(strategyKeys, function (index, value) {<br /> if (browser[value]) {<br /> strategy = strategies[value];<br /> return false;<br /> }<br /> });<br /><br /> if (strategy === null) {<br /> strategy = strategies['default'];<br /> }<br /><br /> return strategy;<br /> }<br /> // ******************************************************<br /><br /> // for use by webkit only<br /> var loadCounter = 0;<br /><br /> // resizeHeight<br /> function resizeHeight(iframe) {<br /> if (options.diagnostics) {<br /> showDiagnostics(iframe, "resizeHeight");<br /> }<br /><br /> // set the iframe size to minHeight so it'll get smaller on resizes in FF and IE<br /> if (options.resetToMinHeight && options.resetToMinHeight === true) {<br /> iframe.style.height = options.minHeight + 'px';<br /> }<br /><br /> // get the iframe body height and set inline style to that plus a little<br /> var $body = $(iframe, window.top.document).contents().find('body');<br /> var strategy = findStrategy($.browser);<br /> var newHeight = strategy(iframe, $body, options, $.browser);<br /> debug(newHeight);<br /><br /> if (newHeight < options.minHeight) {<br /> debug("new height is less than minHeight");<br /> newHeight = options.minHeight + options.heightOffset;<br /> }<br /><br /> debug("New Height: " + newHeight);<br /> if (options.animate) {<br /> $(iframe).animate({height: newHeight + 'px'}, {duration: 500});<br /> } else {<br /> iframe.style.height = newHeight + 'px';<br /> }<br /><br /> options.callback.apply($(iframe), [{newFrameHeight: newHeight}]);<br /> } // END resizeHeight<br /><br /> // debug me<br /> debug(this);<br /> if (options.diagnostics) {<br /> showDiagnostics(this, "each iframe");<br /> }<br /><br /> // if trigger functions are registered, invoke them<br /> if (options.triggerFunctions.length > 0) {<br /> debug(options.triggerFunctions.length + " trigger Functions");<br /> for (var i = 0; i < options.triggerFunctions.length; i++) {<br /> options.triggerFunctions[i](resizeHeight, this);<br /> }<br /> }<br /><br /> // Check if browser is Webkit (Safari/Chrome) or Opera<br /> if ($.browser.webkit || $.browser.opera) {<br /> debug("browser is webkit or opera");<br /><br /> // Start timer when loaded.<br /> $(this).load(function () {<br /> var delay = 0;<br /> var iframe = this;<br /><br /> var delayedResize = function () {<br /> resizeHeight(iframe);<br /> };<br /><br /> if (loadCounter === 0) {<br /> // delay the first one<br /> delay = 500;<br /> } else {<br /> // Reset iframe height to 0 to force new frame size to fit window properly<br /> // this is only an issue when going from large to small iframe, not executed on page load<br /> iframe.style.height = options.minHeight + 'px';<br /> }<br /><br /> debug("load delay: " + delay);<br /> setTimeout(delayedResize, delay);<br /> loadCounter++;<br /> });<br /><br /> // Safari and Opera need a kick-start.<br /> var source = $(this).attr('src');<br /> $(this).attr('src', '');<br /> $(this).attr('src', source);<br /> } else {<br /> // For other browsers.<br /> $(this).load(function () {<br /> resizeHeight(this);<br /> });<br /> } // if browser<br /><br /> }); // $(this).each(function () {<br /> }; // $.fn.iframeAutoHeight = function (options) {<br />}(jQuery)); // (function ($) {<br /></script><br /><iframe frameborder="0" height="300px" scrolling="no" src="http://ninjawords.com" width="100%"></iframe><br /> <script type="text/javascript"> jQuery('iframe').iframeAutoHeight(); </script><br /><br /></div><br /><div style="text-align: center;"><br />NinjaWord </div><br /><div class="separator zemanta-img" style="clear: both; text-align: center;"><br /><a href="http://www.flickr.com/photos/43666171@N07/6499940113" style="margin-left: 1em; margin-right: 1em;"><img alt="Word_BlogNinja" border="0" class="zemanta-img-inserted" height="240" src="http://farm8.static.flickr.com/7001/6499940113_b40f1ca3f8_m.jpg" style="border: medium none; font-size: 0.8em;" width="195" /></a></div><br /><div class="" style="text-align: center;"><br /> </div><br /><div class="zemanta-pixie" style="height: 15px; margin-top: 10px;"><br /><img alt="" class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=65c741d5-378a-4401-a4b5-c7f80bd592df" style="border: none; float: right;" /></div><br /></div><br /> ninjawords.com Ninja Word NinjaWord Read more »