SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multiple Pop-ups?

    Consider the two JavaScript pop-up links below. If I view the web page and click on the first link, then the second, the image inside the pop-up simply changes from one.png to two.png.

    Code:
    <a href="images/one.png" target="new" onclick="window.open( this.href, this.target, 'resizable=1,' ); return false;">ONE</a>
    
    <a href="images/one.png" target="new" onclick="window.open( this.href, this.target, 'resizable=1,' ); return false;">TWO</a>
    Is there some way to modify the script so that a visitor can have both pop-ups open simultaneously?

    Thanks.

  2. #2
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have a different 2nd parameter? (currently this.target).

  3. #3
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SoulScratch View Post
    have a different 2nd parameter? (currently this.target).
    I was thinking along those same lines, but I don't know how you name things in JavaScript. But I did change this.target in the second URL to that.target. After your suggestion, I changed more radically like this...

    Code:
    <a href="images/one.png" target="new" onclick="window.open( this.href, this.target, 'resizable=1,' ); return false;">ONE</a>
    
    <a href="images/one.png" target="new" onclick="window.open( that.href, that.man, 'resizable=1,' ); return false;">TWO</a>
    ...or something like that, but it didn't work. However, I did manage to open the first link in two separate pop-ups, apparently by accidentally clicking the first link twice.

  4. #4
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I figured it out...I just have to change the values for target...

    target="new"

    target="new2"

  5. #5
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes. "that.man" would be invalid since it isn't a real object, so the assignment of the window open would fail.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,597
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    If you make the target "_blank" then each will open a brand new window. Any value not starting with an underscore gives a window name and will reuse that window if it is already open.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  7. #7
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    If you make the target "_blank" then each will open a brand new window. Any value not starting with an underscore gives a window name and will reuse that window if it is already open.
    Thanks for the tip.


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
  •