Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > A function to move between a set of pages

Thread Tools

A function to move between a set of pages
Posts: n/a
My problem starts from two little bits of html pages:


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

and pic_b.htm:

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

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 ='', 'newWin',
'height=475,width=700,scrollbars=0,resizable=0,men ubar=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>')}
// if (pane == 1)
// {newWindow.document.write ("<a><img src=" + url1 + "></a>")}
// else {newWindow.document.write ("<a><img src=" + url2 + "></a>")}

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

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.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing move constructors and move assignment Andrew Tomazos C++ 2 12-12-2011 01:45 PM
I am trying to move spaces to a weblistbox and when I move them... Eduardo78 ASP .Net Web Controls 0 11-03-2005 06:06 PM
Q: move between pages =?Utf-8?B?SklNLkgu?= ASP .Net 7 04-06-2005 09:11 PM
Best way to move data across multiple pages? David Hearn ASP .Net 2 08-09-2003 11:41 AM
Re: How to move between pages Udupa ASP .Net 2 06-25-2003 04:03 PM