Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

JavaScript: Opening 2 links with 1 Click


  • Please log in to reply
13 replies to this topic

#1 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 06 January 2007 - 06:21 AM

Introduction:-
Well here I will show you how to open 2 links with just one click.

Solution:-

Here is the Code, insert this in the Head:-

<SCRIPT LANGUAGE="JavaScript"> 

function DoubleOpen(site1, site2) { 
window.open(site1); 
window.location = site2; 
} 
</script> 

and this goes into the body

<a href="javascript:DoubleOpen('site1', 'site2');">Click Here</a> 

Example:-
<a href="javascript:DoubleOpen('http://www.codecall.net/', 'http://forum.codecall.net/');">Click Here</a> 

Conclusion:-
As Always The Full Code Is Attached And Feedback Is Welcome!

Attached Files


  • 0

#2 xtraze

xtraze

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 872 posts

Posted 06 January 2007 - 07:39 PM

Nice, I think I will try to use this for IPB and make another window oen requesting unregistered members to sign-up.
  • 0

#3 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 07 January 2007 - 01:32 AM

Nice, I think I will try to use this for IPB and make another window oen requesting unregistered members to sign-up.


I'm happy that you found a use for this ;)
  • 0

#4 xtraze

xtraze

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 872 posts

Posted 07 January 2007 - 11:43 PM

I always think of uses for tutorials being posted here. I may not use all but maybe someone else can. Look at all replies I have made dude, most of them are alternates or uses.
  • 0

#5 AfTriX

AfTriX

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 541 posts

Posted 12 January 2007 - 01:32 AM

Thanks!
Nice trick of parsing a couple of arguments to the function.

windows.location = xxx;

The code that I'v learnt now.
  • 0

#6 TheJun

TheJun

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 08 August 2007 - 02:55 PM

Thank you very much.
  • 0

#7 broomy

broomy

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 02 October 2011 - 01:28 AM

I used this code:

<head>
<SCRIPT LANGUAGE="JavaScript">

function DoubleOpen(site1, site2) {
window.open(site1);
window.location = site2;
}
</script>
</head>

<body>
<a href="http://stats.justhost.com/track?c4d46e520aad528107f000dfd9c8d553d/', 'http://thepiratebay.org/torrent/6562848/');">Click Here</a>
</body>


but it didn't work, please help what have i done wrong?
  • 0

#8 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 02 October 2011 - 06:47 PM

You are trying to open two links in the CURRENT window. That's just not possible. Try setting the target to new.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#9 broomy

broomy

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 03 October 2011 - 07:45 AM

You are trying to open two links in the CURRENT window. That's just not possible. Try setting the target to new.


Not trying to sound dum or anything, but i'm new to HTML just trying to learn a few useful tricks. But how to you change the target to new window?
  • 0

#10 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 03 October 2011 - 07:49 AM

HTML Links
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#11 Epatron

Epatron

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 54 posts

Posted 03 October 2011 - 08:25 PM

Thanks! I was thinking to learn more javascript so I can really use it ^^!
So thanks much! :)
  • 0

Young student from Finland!
PS: 15-year-old! :)


#12 VakhoQ

VakhoQ

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 126 posts

Posted 19 December 2011 - 11:18 PM

nice work :)
  • 0
GNU/Linux Is the Best.




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download