1
<frameset name="main">
 <frame src="leftnav.php" name="leftframe"/>
 <frame  src="dashboard.php" name="rightframe" bgcolor="#000000"/>
</frameset>

Hey. I want to execute some JavaScript in the rightframe and that should then affect in the left frame.

I guess the question is... what do I need to prefix my javascript with so it is accessible in the left frame?

3
  • 3
    frames are BAD ! We're not in the 90's anymore Commented Dec 29, 2010 at 8:55
  • But sometime we need to fix or modify old stuffs without rewrite the page. Commented Dec 29, 2010 at 9:05
  • 1
    Precisely. Sometimes it is cheaper to not replace the templating system on a 2000 file PHP app... Commented Jan 3, 2011 at 11:29

4 Answers 4

3

If you are in a page wich is in the right frame and you want to access an element in a page in the left frame you can use for example:

var table=parent.leftframe.document.getElementById("information");
Sign up to request clarification or add additional context in comments.

Comments

1

You can: parent.leftframe.var_name and parent.leftframe.function_name()

Comments

1

In a comment to the original question (above), @Valentin mentions that frames are "bad," but does not explain further. Here are some references that do:

https://softwareengineering.stackexchange.com/q/144515/290869

Frames deprecated in HTML5 but not iFrames

Why are frames deprecated in html?

Comments

0

index.html:

...
<script type="text/javascript">
    function hello () {
        alert('Say hello!');
    }
</script>
<frameset name="main">
 <frame src="frame1.html" name="leftframe"/>
</frameset>
...

frame1.html

...
<script type="text/javascript">
    parent.hello(); // OR parent.YOU_FRAME_NAME
</script>
...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.