Skip to content

Instantly share code, notes, and snippets.

@gabrielschulhof
Created March 8, 2014 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielschulhof/9422957 to your computer and use it in GitHub Desktop.
Save gabrielschulhof/9422957 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<title>Load A Sequence Of Pages In An IFrame</title>
<script src="external/jquery/jquery.js"></script>
<style>
body {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
background: red;
}
.main-frame {
margin: 0;
width: 100%;
height: 100%;
}
</style>
<script>
( function( $ ) {
// To really measure load time, use a local server and point fonts.googleapis.com to localhost via
// /etc/hosts
// Note: The load time will include the PHP processing time for all the includes.
var
elapsedTime = 0,
startTime,
index = -1,
// Some demos are commented out because they access outside Web sites, so that can delay their
// loading
urlList = [
"demos/listview-collapsible-item-indented/index.php",
"demos/index.php",
"demos/panel-responsive/index.php",
"demos/transitions/index.php",
"demos/body-bar-classes/index.php",
"demos/checkboxradio-radio/index.php",
"demos/popup-dynamic/index.php",
"demos/_assets/js/index.php",
"demos/_search/index.php",
"demos/textinput/index.php",
"demos/toolbar-fixed/index.php",
"demos/toolbar-fixed-external/index.php",
// "demos/listview-nested-lists/index.php",
"demos/toolbar-fixed-forms/index.php",
"demos/pages/index.php",
"demos/toolbar-fixed-persistent/index.php",
"demos/listview-grid/index.php",
"demos/collapsible/index.php",
// "demos/datepicker/index.php",
"demos/intro/index.php",
// "demos/popup-iframe/index.php",
"demos/slider/index.php",
"demos/controlgroup/index.php",
"demos/table-reflow-heading-groups/index.php",
"demos/loader/index.php",
"demos/listview-autocomplete-remote/index.php",
"demos/old-faq-pages/index.php",
"demos/flipswitch/index.php",
"demos/table-column-toggle-options/index.php",
"demos/panel-styling/index.php",
"demos/listview-autodividers-selector/index.php",
"demos/collapsible-dynamic/index.php",
"demos/navigation-php-redirect/index.php",
"demos/button/index.php",
// "demos/map-list-toggle/index.php",
"demos/controlgroup-dynamic/index.php",
"demos/listview-autocomplete/index.php",
"demos/toolbar-fixed-fullscreen/index.php",
"demos/popup-outside-multipage/index.php",
"demos/pages-dialog/index.php",
"demos/collapsibleset/index.php",
"demos/toolbar/index.php",
"demos/forms/index.php",
"demos/panel-swipe-open/index.php",
"demos/forms-gallery/index.php",
"demos/navbar/index.php",
"demos/filterable/index.php",
"demos/selectmenu-custom-filter/index.php",
"demos/forms-label-hidden-accessible/index.php",
"demos/grids/index.php",
"demos/rangeslider/index.php",
// "demos/backbone-requirejs/index.php",
"demos/popup-alignment/index.php",
"demos/icons-grunticon/index.php",
"demos/table-column-toggle/index.php",
"demos/selectmenu-custom/index.php",
"demos/panel-external/index.php",
"demos/popup/index.php",
"demos/icons/index.php",
"demos/table-column-toggle-example/index.php",
"demos/table-column-toggle-heading-groups/index.php",
"demos/theme-default/index.php",
"demos/toolbar-external/index.php",
"demos/swipe-list/index.php",
"demos/navigation/index.php",
"demos/listview/index.php",
"demos/table-reflow-styling/index.php",
"demos/popup-image-scaling/index.php",
"demos/listview-collapsible-item-flat/index.php",
"demos/forms-field-contain/index.php",
"demos/button-markup/index.php",
"demos/checkboxradio-checkbox/index.php",
"demos/slider-flipswitch/index.php",
"demos/listview-autodividers-linkbar/index.php",
"demos/forms-disabled/index.php",
"demos/grids-buttons/index.php",
"demos/tabs/index.php",
"demos/map-geolocation/index.php",
"demos/toolbar-fixed-persistent-optimized/index.php",
"demos/grids-custom-responsive/index.php",
"demos/swipe-page/index.php",
"demos/toolbar-dynamic/index.php",
"demos/table-reflow/index.php",
"demos/panel-fixed/index.php",
"demos/panel/index.php",
"demos/navigation-hash-processing/index.php",
"demos/table-reflow-stripes-strokes/index.php",
"demos/slider-tooltip/index.php",
"demos/navigation-linking-pages/index.php",
"demos/rwd/index.php",
"demos/selectmenu/index.php",
"demos/popup-arrow-size/index.php",
"demos/theme-classic/index.php"
],
instances = {};
// Make the widget factory call this function from within the iframe whenever it instantiates a new
// widget to get a tally of all the widgets in the demos list. You can use
// window.top.recordNewInstance( fullName ) right before $.data( element, new object( ... ) )
window.recordNewInstance = function( fullName ) {
instances[ fullName ] = ( instances[ fullName ] || 0 ) + 1;
}
function newUrl() {
var currentTime, output, instanceIndex;
index++;
if ( index < urlList.length ) {
currentTime = ( new Date() ).getTime();
if ( startTime !== undefined ) {
elapsedTime += currentTime - startTime;
}
startTime = currentTime;
$( "iframe" ).attr( "src", urlList[ index ] );
} else {
output = "";
for ( instanceIndex in instances ) {
output += instanceIndex + ": " + instances[ instanceIndex ] + "\n";
}
alert( elapsedTime + "\n" + output );
}
}
$( function() {
$( window ).on( "load", function() {
setTimeout( newUrl, 1000 );
});
$( "iframe" ).on( "load", function() {
setTimeout( newUrl, 0 );
});
});
})( jQuery );
</script>
</head>
<body>
<!-- To turn off JS inside the iframe, add the attribute
sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-top-navigation"
to the iframe -->
<iframe class="main-frame" seamless="seamless"></iframe>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment