Results 1 to 3 of 3

Thread: Open multiple window at once

  1. #1
    Join Date
    Nov 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Open multiple window at once

    Hi all, I would like to make a link on my page to open multiple window at once. For example, clicking on the link "Click here" will open 3 new windows at once, each pointing to a different page. I know it is possible to do this with javascript window.open but the page I wanted to open will be dynamic.

    In another word, I want a link to open up multiple pages in my rss feed. So the link is not the same each time. May I know how to do this? I would appreciate if you can show me the code =) Thanks in advance

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    How are the links being placed? You could contain them in one container and loop through all the links, and assign an onclick event on each of them:
    Code:
    <script type="text/javascript">
    var ray={
    /**
    * links array accepts three params
    @ param1 - URL you wish to open
    @  param2 - name of the window
    @ param3 - window preferences
    */
    links:
    	[
    		['http://www.google.com','window1','width=300,height=300'],
    		['http://www.yahoo.com','window2','width=500,height=500,top=100,left=100'],
    		['http://www.dynamicdrive.com','window3','left=500,width=300,height=300'] // No comma
    	], // Links you wish to open together with the window name and the preferences
    loop:function(el)
    	{
    	var lnkArr=this.getID(el).getElementsByTagName('a');
    	for(var i=0;i<lnkArr.length;i++)
    		{
    		lnkArr[i].onclick=function()
    			{
    			for(var c=0;c<ray.links.length;c++)
    				window.open(ray.links[c][0],ray.links[c][1],ray.links[c][2]);
    			}
    		}
    	},
    getID:function(el)
    	{
    		return document.getElementById(el);
    	}
    }
    window.onload=function()
    	{
    		ray.loop('contain'); // Pass the ID of the container here
    	}
    </script>
    <div id="contain">
    <a href="#">Top Anchor</a><br>
    <a href="http://www.google.com">http://www.google.com</a><br>
    <a href="http://www.yahoo.com">http://www.yahoo.com</a><br>
    </div>
    Hope that helps.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. #3
    Join Date
    Nov 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks. I am aware of that code but the function I am after is not exactly that. I want to open up multiple windows from my rss feed. So I will not know the url for the webpage in advance.

    For example: http://news.google.com/?ned=us&topic=t&output=rss

    If I wanted to open the latest 3 posts from Google news feed. Is there a way to dynamically assign the feed title and use javascript to open them?

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
  •