ComputerUser
ComputerUser

Reputation: 4888

Executing Javascript in a frameset

<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?

Upvotes: 1

Views: 3203

Answers (4)

CODE-REaD
CODE-REaD

Reputation: 3058

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?

Upvotes: 1

beshkenadze
beshkenadze

Reputation: 645

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>
...

Upvotes: 0

user536158
user536158

Reputation:

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");

Upvotes: 3

pinichi
pinichi

Reputation: 2205

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

Upvotes: 1

Related Questions