Cannot replace frame contents using javascript from another frame

I have a 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 frame (nav), I use a javascript function that includes this line

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

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

0
source share
2 answers

Use this instead:

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

instead:

 parent.base_frame.location.href = options; 

he 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> 
+1
source

You can assign an identifier for each frame and then do it and then replace the line

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

I assume you already defined href in your code.

0
source

Source: https://habr.com/ru/post/953144/


All Articles