#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Posts
    11
    Rep Power
    0

    Unhappy Annoying Javascript pop up problem


    Hi,

    I have a page that lists records from a database using PHP into a table. The table gets quite long and you need to scroll down the page. Each record has a link that equals # and an onclick event that opens a pop-up window using the following script.


    function profile(webpage){
    var mywin = open("profile.php?id=" + webpage, "", "toolbar=no,width=600,height=450,scrollbars=yes");
    }


    The problem I am having is that if you are halfway down the page when you click a link the pop up window opens fine but the parent window resets and the page jumps to the top. Which is really annoying for the user because they lose their place on the page.

    Can anyone help with this?

    Thanks
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Posts
    2
    Rep Power
    0
    How do u make the call of the function in the link that opens the popup?

    Stiwi
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Posts
    11
    Rep Power
    0
    I use the following code:

    <a href='#' onclick='profile(37)'>Link text</a>
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Posts
    2
    Rep Power
    0
    Try a voided link:

    <a href='javascript:void(0)' onclick='profile(37)'>Link text</a>

    Stiwi

    PS: Dont forget to drop the blank between java and script, it's inserted by the forum to prevent excecution of javascript in posts i think
    Last edited by Stiwi; September 3rd, 2001 at 07:00 AM.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Posts
    11
    Rep Power
    0
    Thanks a lot. That worked a treat.

IMN logo majestic logo threadwatch logo seochat tools logo