Last post Nov 23, 2006 08:16 AM by Rubo
Nov 20, 2006 10:33 PM|koese|LINK
How do I position the content of an I-frame when this content is non-editable (link to website) ?
Is there a way to shift the content position inside the iframe on initial load?
For example, my iframe is 200 x 200 px size. I want it to display content of a page that's 300px from the top and 100 px from the left.
Nov 21, 2006 07:34 AM|Rubo|LINK
You can do it by accessing iframe document object. For example, window["iframe_name"].document.body.marginLeft = "-50px";
Nov 21, 2006 11:11 AM|koese|LINK
I have tried your option but no luck am i going wrong some where
<body onload=window('frameA1').document.body.marginLeft = '-100px';>
<iframe name="frameA1" height="400" width="400" src="http://www.yahoo.com"></iframe>
Nov 21, 2006 01:34 PM|Rubo|LINK
There are some mistakes in your code. But, remember code below is working only when
<URL> domain and current page domain are same, otherwise browsers have denied access to body property of iframe document (for example IE 7 or Firefox 2).
<iframe id="iframe1" style="height: 200px; width: 200px;"></iframe>
var t = window.document.getElementById("iframe1");
t.onload = function()
t.contentWindow.document.body.style.marginLeft = "-100px";
Nov 21, 2006 10:24 PM|koese|LINK
Thanks for your effort
You are right about the body property of the Iframe as it is giving an error (Access denied) if I use different domain.
But the main point is still I am not getting the inner frame content (-100px) left, as it was misleading, if we had some textbox on the page with focus in it then it is showing the textbox with cursor, and I thought it is working fine because the textbox
on the page is 200px from left, but if we use some other normal plain page and try to align left of -100px on the frame, then its not doing the right thing what we are looking for.
Hope you understood what I am trying to say.
Nov 23, 2006 02:31 AM|koese|LINK
The solution is found at
which is not moving or placing an Iframe, but moving the inside content of the IFrame
Nov 23, 2006 08:16 AM|Rubo|LINK
Yes, it just scrolls entire content of iframe. Also you can try to disable iframe scrollbars, but user always can scroll it even with disabled scrollbars.