I am working on a webpage that has some frames that contain webpages that are on other servers. Some of the frames are smaller than the webpages that they contain; also, some of these embedded webpages may start out at named anchors (
) which result in the content being scrolled to the right.
I would like to scroll each frame, as soon as that frame first finishes loading, in one of a few ways: all the way to the left, all the way to the right, or leaving the default horizontal position.
At this time, the only browser I need to support is Firefox 5.
As suggested in http://stackoverflow.com/questions/1...omment-6499395
I have produced a main and a subsidiary HTML file.
I think the problem is finding an object syntax that can scroll one frame in my setup. For example:
The "blah" is the part I am looking for. I think that once I have this, writing the code to determine which frame to scroll, and in which direction, will be straightforward.
I can consider a different approach than the one described in the stackoverflow.com article above, but I prefer that it be simple. I do not
have access to the embedded webpages to change them.
Simplified versions of my 2 HTML files are as follows. The real "main.html" will eventually have several nested framesets, some with the contents stacked one above the other (
) and some with the contents arranged left to right (
// This code causes each "shim frame" to load the webpage specified by the
// mandatory "data-URL" custom attribute of the <frame> definition.
var theFrames = document.getElementsByTagName("frame")
for(var i = 0; i < theFrames.length; i++)
var aFrame = theFrames[i]
var targetURL = aFrame.getAttribute("data-URL")
aFrame.contentDocument.getElementsByTagName("frame").src = targetURL
<frameset cols="45%,*" onload="fillTheShimFrames()">
<frame src="frame_shim.htm" id="0"
<frame src="frame_shim.htm?s=L" id="1"
frame_shim.htm - after this code listing, there is a note about
if (document.getElementsByTagName("frame").src != "about:blank")
scrollDirection = getSearchParam("s")
// scroll all the way to the left
// scroll all the way to the right
<frame src="about:blank" onload="scrollTweak()">
is a helper function to decode the part of the URL after the question mark ("?"). For clarity, I left this function out of the code listing. The function is similar to the one at http://stackoverflow.com/questions/5...#answer-523293
or you can hard-code
in place of
if you want to test the above HTML.
It is fine if the call to
is in "main.htm" instead of "frame_shim.htm." I have tried putting it in both files, and in both cases I haven't found an object reference syntax that works.
Thanks in advance for suggestions.