A function to move between a set of pages

C

ciaran

<!--
My problem starts from two little bits of html pages:

pic_a.htm:

<body>
<a href='pic_b.htm'>B</a>
<a><img src='pic_a.gif'></a>
</body>

and pic_b.htm:

<body>
<a href='pic_a.htm'>A</a>
<a><img src='pic_b.gif'></a>
</body>

The idea is to display either of the pages, which will show an image
and a link to the other page. By clicking on the links we can switch
back and forward between the two pages. It's a bit like a form of
tabbed pages.

It works well. Now I want to use Javascript to generalize it later
without creating hundreds of tiny HTML files. (I'll be grouping the
images in sets of four, rather then two, and I'll have hundreds of
sets.) But I don't know if it can be done. Here's how I've tried.
-->


<script language="JavaScript">
function myFunction(pane,url1,url2){

newWindow = window.open('', 'newWin',
'height=475,width=700,scrollbars=0,resizable=0,menubar=0,toolbar=0,status=1,location=0,directories=0,left=50,top=25');

if (pane == 1)
{newWindow.document.write ('<a href="javascript:myFunction(2, \'' +
url1 + '\', \'' + url2 + '\')">B</a>')}
else {newWindow.document.write ('<a href="javascript:myFunction(1, \''
+ url1 + '\', \'' + url2 + '\')">A</a>')}
newWindow.document.writeln("<BR>")
// if (pane == 1)
// {newWindow.document.write ("<a><img src=" + url1 + "></a>")}
// else {newWindow.document.write ("<a><img src=" + url2 + "></a>")}
newWindow.document.writeln("<BR>")
}
</script>

<body>
Start in
<a href="javascript:myFunction(1, 'pic_a.gif', 'pic_b.gif')">here</a>
</body>


<!--
I get my "main" page, I click the link to the first of the pair of
pages, and the first page of the pair pops up. Now, on hovering over
the link to the second page, the text of the Javascript function call
appears on the status bar, completely correct, but clicking on it
produces "Error in page".

I've commented out the "document.write"s for the two images, though it
doesn't leave much to see. You can use any pair of images, or none,
for testing purposes.

Is it the recursion which is the trouble? If so, what can be done?

Or does something need fixed with the second creation of the window?

Thanks for any ideas.
-->
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top