1

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.

user877329
  • 6,717
  • 8
  • 46
  • 88
  • You should avoid using framset the reason for this is explained here: http://stackoverflow.com/a/4263583/1960455 (with html5 they are also marked as deprecated). Instead of framsets you should you should create normal html pages in combination with loading content with ajax. – t.niese Jun 06 '13 at 13:07
  • I want to do it without AJAX. Also, In this particular case, I do not see what is wrong conceptually with frames. – user877329 Jun 06 '13 at 13:21
  • 1. View an image. 2. Copy / paste the address from the address bar. 3. Send it to a friend. 4. Wonder why the image they see is not the image you see. *Frames break linking, which is a fundamental feature of the WWW*. – Quentin Jun 06 '13 at 21:09
  • ...Or rightclick in the frame. Choose "This frame" and choose your options. In FF at least – user877329 Jun 07 '13 at 14:38
  • I actually see one reason for frames. It does not bloat the browsers history! – user877329 Jun 27 '13 at 06:42

1 Answers1

0

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>
Stano
  • 8,749
  • 6
  • 30
  • 44