Page 1 of 1

Snap an iframe

Posted: Fri Dec 11, 2009 6:27 pm
by lmchaelichkatel
Hello

I would like to achieve a goal but I found it so hard, in a webpage if someone point on a link a snap shot open and contain an iframe of the webpage of that url that user points on it. I also ask how to control width and height of the iframe when it is larger page a scroll bar appears.

Some people wants only a screen capture of the page of the url, but I am asking for an iframe instead.

Thank you

Re: Snap an iframe

Posted: Tue Dec 15, 2009 4:09 pm
by joshuab
A reference to the iframe element is obtained via its id attribute. Theoretically, this should allow for script control of attributes like scrolling and frameborder. In practice, modifying these attributes in script may have no effect. You can use the reference to the iframe element to set its style and src properties with more consistent results.

a simple example:

Code: Select all

var iframeElement = document.getElementById(id);
iframeElement.style.width = "600px";
 
in detail

Code: Select all

 
function setIframeHeight(id, h) {
    if ( document.getElementById ) {
        var theIframe = document.getElementById(id);
        if (theIframe) {
            dw_Viewport.getWinHeight();
            theIframe.style.height = Math.round( h * dw_Viewport.height ) + "px";
            theIframe.style.marginTop = Math.round( (dw_Viewport.height - 
                parseInt(theIframe.style.height) )/2 ) + "px";
        }
    }
}
 
window.onload = function() { setIframeHeight('ifrm', .8); }
window.onresize = function() { setIframeHeight('ifrm', .8); }
 

Web Development Services