By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,728 Members | 1,355 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,728 IT Pros & Developers. It's quick & easy.

using scrollBy in conjunction with frames

P: n/a
I've been trying to get the scrollby javascript feature to scroll
through frames. My end goal is to make my own scroll buttons to use
for navigation through the frame but I figured I would start simple.
I would load a frameset and just move the correct frame by 100 pixels
right and 100 pixels down. Here is the code I am using:
<html>
<script TYPE="text/javascript">
function scrollme()
{parent.frames[1].scrollBy(100,100)}
</script>

<FRAMESET onload="scrollme();" COLS="300,300,300">
<frame src = http://www.yahoo.com name="yahoo">
<frame src = http://www.google.com name="google">
<frame src = http://www.cnn.com name="cnn">
</frameset>
</html>
The line that really matters is of course
{parent.frames[1].scrollBy(100,100)} and I've seen (and tried) this
written many ways. It's got to be a syntax issue. I've tried:

parent.frames.yahoo.scrollBy(100,100)
parent.frames.yahoo.window.scrollBy(100,100)
parent.frames[yahoo].window.scrollBy(100,100)

and more variants. I though maybe the function wasn't running so I
replaced my frames line with alert('Test!') and the msgbox came up.
Any ideas?

Sara
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
your name here wrote:
The line that really matters is of course
{parent.frames[1].scrollBy(100,100)} and I've seen (and tried) this
written many ways. It's got to be a syntax issue. I've tried:

parent.frames.yahoo.scrollBy(100,100)
parent.frames.yahoo.window.scrollBy(100,100)
parent.frames[yahoo].window.scrollBy(100,100)

<snip>

How about:

top.framename.scrollBy(100,100);
top.frames[1].scrollBy(100,100);
Jul 23 '05 #2

P: n/a
Ivo
"your name here" wrote
<html>
<script TYPE="text/javascript">
function scrollme()
{parent.frames[1].scrollBy(100,100)}
</script>

<FRAMESET onload="scrollme();" COLS="300,300,300">
<frame src = http://www.yahoo.com name="yahoo">
<frame src = http://www.google.com name="google">
<frame src = http://www.cnn.com name="cnn">
</frameset>
</html>


Cross-domain security measures prevent you from performing any action on
documents that are not from the very same domain as the document containing
the script. See for more info for example <
http://www.mozilla.org/projects/secu...me-origin.html >.
There is no workaround. If your page resides on Google, the above will work
because parent.frames[1] will contain a document from the same domain.
Otherwise, wait till your page shows up in their cache, and then try
again...
--
Ivo
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.