SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member lorax156's Avatar
    Join Date
    Jul 2003
    Location
    new york
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    question about pop-up windows

    Hello... Im new to using html/javascript and had a question about pop-ups. Currently when I test my page and initally click on the link that is to generate the pop-up, everything works fine. However, when I click on the link again, instead of having a pop-up appear, the link opens up in my current browser(_self)... is there anyway to avoid this problem? i.e. can I force a pop-up link to ONLY open in a pop-up window ... and if so, if the pop-up is currently open can I reject the link request?

    here is the code I am using(put in a little test page with a link to google... click the link once then please try it again to see what my problem is... thanks):

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function popup(URL) {
    var windowprops="location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes,left=0,top=0,width=300,height=300";
    popup = window.open(URL,"popped",windowprops);
    }
    // End -->
    </script>
    </head>
    <body>
    <a href="http://www.google.com/" onclick="popup(this.href);return false;">click here</a>

    </body>
    </html>

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    function popup(URL) {
    ...
    popup = window....

    1) don't name 2 different things the same -- the computer is stupid and gets easily confused

    2)
    var newwin;
    function popup(url)
    {
    if (!newwin)
    newwin= window.open......
    else
    alert('already open')
    }

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •