Paul Taylor
Paul Taylor

Reputation: 13130

Unable to replace contents of frame using javascript from another frame

I have frameset defined as follows

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/html" xml:lang="en" lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head>
<frameset cols="40%,*">
<frame src="FixSongsReport_00155_2013-09-05-13-13-46_index.html" name="nav">
<frame src="FixSongsReport_00155_2013-09-05-13-13-46_summary.html"  name="main">
</frameset>

On my left hand frame (nav) I a javascript function that includes this line

window.frameElement.frames[1].document.location.href = href

to try and update the right hand side frame (main) to point to the new href but it has no effect, what am i doing wrong ?

Upvotes: 0

Views: 2536

Answers (2)

Use this instead:

top.frames["base_frame"].location = options;

instead of:

parent.base_frame.location.href = options;

it will work for u.

Where:

<frameset border="0" frameborder="0" rows="65,*">

        <frame src="index display on top" name="options">

        <frame src="pages i wanna display" name="base_frame">

    </frameset>

Upvotes: 1

user2240041
user2240041

Reputation: 1

You could assign an id to each frame and then do this, then replace your line with

document.getElementById('frame2').src= href;

I assume you already defined href in your code.

Upvotes: 0

Related Questions