Carl3003
asked on
can i lock the iframe scroll bar when I am trying to open another link?
Hi,
Basically i have a page with couple of buttons and an iframe. Each button has a different property which onclick event i pass to the iframe location and the iframe reloads depending the value which i am passing. That works fine. My problem is that every time the iframe reloads, the scroll bar comes as the top of the page. Since my iframe has a long list, and iframe hight is relatively small, the users needs to scroll down to review the data. When the user press another button, the iframe scroll goes by default on the top of the page and the user needs to scroll down again. This is somewhat annoying. Do you have any suggestions?
Thanks in advance.
Basically i have a page with couple of buttons and an iframe. Each button has a different property which onclick event i pass to the iframe location and the iframe reloads depending the value which i am passing. That works fine. My problem is that every time the iframe reloads, the scroll bar comes as the top of the page. Since my iframe has a long list, and iframe hight is relatively small, the users needs to scroll down to review the data. When the user press another button, the iframe scroll goes by default on the top of the page and the user needs to scroll down again. This is somewhat annoying. Do you have any suggestions?
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hope this helps,
Neal.
Here's the code to go into the main page:
<script type=text/javascript>
var scrollX, scrollY;
function loadPage() {
if (document.all) { // IE
if (!window.frames[0].documen
scrollX = window.frames[0].document.
else
scrollX = window.frames[0].document.
if (!window.frames[0].documen
scrollY = window.frames[0].document.
else
scrollY = window.frames[0].document.
}
else { // Mozilla
scrollX = window.frames[0].pageXOffs
scrollY = window.frames[0].pageYOffs
}
window.frames[0].location=
}
function setScroll() {
window.frames[0].scrollTo(
}
</script>
--------------------------
In the frame page add an onLoad event:
<body onload="parent.setScroll()