SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    uk
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I create a link that pops up many windows at once?

    I need to do this for my blog, just curious if there is a way to do this?

    I.E you click the one link and it pops up say 5 windows going to other sites.

    It's so that my users can click on one link and be taken to 5 different band sites as my blog will be a band fan site.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,445
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)

    5 pop-ups

    I would advise not to open any pop-ups let alone 5 There is a reason pop-up blockers are popular. And I don't see why a user would necessarily want to see all 5 band sites, especially at once, even with a broadband connection.
    The best would probably be to give them the choice. eg.
    HTML Code:
    <a href="http://band1.com" target="_blank">Band 1</a>
    <a href="http://band2.com" target="_blank">Band 2</a>
    <a href="http://band3.com" target="_blank">Band 3</a>
    <a href="http://band4.com" target="_blank">Band 4</a>
    <a href="http://band5.com" target="_blank">Band 5</a>

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    uk
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague
    I would advise not to open any pop-ups let alone 5 There is a reason pop-up blockers are popular. And I don't see why a user would necessarily want to see all 5 band sites, especially at once, even with a broadband connection.
    The best would probably be to give them the choice. eg.
    HTML Code:
    <a href="http://band1.com" target="_blank">Band 1</a>
    <a href="http://band2.com" target="_blank">Band 2</a>
    <a href="http://band3.com" target="_blank">Band 3</a>
    <a href="http://band4.com" target="_blank">Band 4</a>
    <a href="http://band5.com" target="_blank">Band 5</a>
    Uh that's not what I asked for. My users want this, that's why I'm asking.

  4. #4
    SitePoint Member tats's Avatar
    Join Date
    Aug 2006
    Location
    NCR
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i myself hate many pop ups so i suggest to enumerate them in your link area

  5. #5
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The syntax for opening a window in JavaScript is:
    window.open("URL","window_name","feature_list")

    The feature list can have things such as height=400,width=600,~etc..

    To get 5 windows, simply rinse and repeat.

    Notes: Variable substitution may be implemented instead of literal strings and loops may be instituted for repetition. If you use the same window name, however, the new URL will simply replace the old in the same window. Most common is to assign the window.open result to a variable name, as in: winX=window.open(~etc.) as the window may then be manipulated through the variable.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Hopefully everyone will be running a decent popup blocker that blocks such stupid code from working. Decent popup blockers will allow ONE popup window to be opened in response to a specific request to open it by your visitor.

    To get the window.open to open multiple windows the window name must either be different for each wildow or set to _blank
    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
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,445
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)

    pop-ups

    Quote Originally Posted by martynjackson
    My users want this
    There may be some users that aren't smart enough to realize exactly what they're asking for. So even though you know better, do you give it to them anyway? I suppose as long as the link clearly warns users and you provide another alternative for the users that aren't asking for this "feature", then you should minimize the risk of losing your visitors.

  8. #8
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall
    Hopefully everyone will be running a decent popup blocker . . .
    Opera does that, but FF and Konq do not with the following code: <a href="#" onclick="window.open('','','height=200,width=300,top=200');window.open('','','height=200,width=300,top=400');return false;">test</a>

    So, as with pornography, I guess decency is in the eye of the beholder.

  9. #9
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,445
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)

    pop-up blocking

    Quote Originally Posted by JVLB
    but FF and Konq do not
    I can't comment on Konquerer, but thankfully the Firefox GreaseMonkey extension allows for additional features that the browser lacks.
    This simple user script helps a lot.
    Code:
    // ==UserScript==
    // @name           Clear onClick value
    // @description    Clears onclick value
    // @include        *
    // ==/UserScript==
    
    var allLinks, thisLink, js;
    
    allLinks = document.evaluate(
    			'//a[@href]',
    			document,
    			null,
    			XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    			null
    			);
    	for (var i = 0; i < allLinks.snapshotLength; i++)
    	{
    		thisLink = allLinks.snapshotItem(i);
    		if(js = thisLink.getAttribute('onclick'))
    		{
    			thisLink.setAttribute("onClick", "");
    		}
    	}
    *NOTE* Thus script will muck up links that have justifiable onclicks. For a userscript that changes pop-ups to regular links (and doesn't just remove the onclick value) please go to http://userscripts.org/scripts/show/5273 or http://www.mittineague.com/dev/nopopuplinks.user.js
    Last edited by Mittineague; Aug 23, 2006 at 01:05. Reason: replace with better working example


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
  •