A function to move between a set of pages

Discussion in 'Javascript' started by ciaran@oduibhin.freeserve.co.uk, May 3, 2006.

  1. Guest

    <!--
    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.
    -->
    , May 3, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Udupa

    Re: How to move between pages

    Udupa, Jun 25, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,059
  2. David Hearn
    Replies:
    2
    Views:
    357
    David Hearn
    Aug 9, 2003
  3. =?Utf-8?B?SklNLkgu?=

    Q: move between pages

    =?Utf-8?B?SklNLkgu?=, Apr 6, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    2,222
    Steve C. Orr [MVP, MCSD]
    Apr 6, 2005
  4. Eduardo78
    Replies:
    0
    Views:
    241
    Eduardo78
    Nov 3, 2005
  5. Andrew Tomazos
    Replies:
    2
    Views:
    594
    Nobody
    Dec 12, 2011
Loading...

Share This Page