passbe/beef-migration-test-2 — Issue #224: Add Module: iFrame Redirect 
Author: passbe
Created: 2011-12-05 09:32:40+00:00
State: open

Add a module that permits redirection of a 100% x 100% foreground iFrame. The browser will remain hooked to the framework and continue accepting commands.

Thanks Yori for the following code which will provide a head start in the implementation.

function do_main(){
var iframe = document.createElement('IFRAME');
iframe.src = 'URL';
// Calculate window size
// Source: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
var myWidth = 0, myHeight = 0;
var wPad = 0, hPad = 0;
if( typeof window.innerWidth != 'undefined' ) {
// Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
wPad = 10;
hPad = 20;
} else if (document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6
myWidth = document.body.scrollWidth;
myHeight = document.body.scrollHeight;
wPad = 30;
hPad = 30;
} else {
// IE 7+
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
wPad = 30;
hPad = 30;
}

iframe.setAttribute("width", (myWidth - wPad) + "px");
iframe.setAttribute("height", (myHeight - hPad) + "px");
iframe.setAttribute("style", "height:" + (myHeight - hPad) + "px; width:" + (myWidth - wPad) + "px; border:0px");
iframe.setAttribute("scrolling", "auto");
iframe.setAttribute("id", "f");
document.title = "TITLE";
document.body.innerHTML="";
document.body.appendChild(iframe);

return "IFrame Redirect Sent";
}

var result_value = do_main();

Original link: http://code.google.com/p/beef/issues/detail?id=121