質問

It is a long time since I programmed web. How do I perform javascript frameset navigation (or replace the frameset with an exact equivalent):

<frameset rows="*,32">
  <frame src="about:blank" id="viewer">
  <frame src="cgi/browse.exe?images">
</frameset>

The webpage generated by browse.exe conains an javascript array with a list of files, and two buttons: previuos and next. When the user clicks next, next file should be displayed in the "viewer".

I have tried

parent.frames["viewer"].location.assign("...");

without success in FF. It works in IE. Note that the navigation works fine as long as I stay inside the same frame.

役に立ちましたか?

解決

Try to replace the id with the name attribute, then it should work well in all browsers. Tested it on these pages:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>index.html</title>
</head>
<frameset cols="240,*">
<frame name="fmenu" src="leftmenu.html" scrolling="yes"/>
<frame name="viewer" src="page1.html" scrolling="yes"/>
<noframes><p>noframes</p></noframes>
</frameset>
</html>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>leftmenu.html</title>
</head>
<body>
<a onclick="window.parent.frames['viewer'].location.assign('page2.html')">test</a>
</body>
</html>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>page1,2.html</title>
</head>
<body>
<p>START PAGE</p>
</body>
</html>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top