Jump to content

JavaScript: Opening 2 links with 1 Click

- - - - -

  • Please log in to reply
11 replies to this topic

#1
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
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



#2
xtraze

xtraze

    Programming God

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

#3
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts

xtraze said:

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 ;)

#4
xtraze

xtraze

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 910 posts
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.

#5
AfTriX

AfTriX

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 586 posts
Thanks!
Nice trick of parsing a couple of arguments to the function.

windows.location = xxx;

The code that I'v learnt now.

#6
TheJun

TheJun

    Newbie

  • Members
  • Pip
  • 1 posts
Thank you very much.

#7
broomy

broomy

    Newbie

  • Members
  • Pip
  • 2 posts
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?

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 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
You are trying to open two links in the CURRENT window. That's just not possible. Try setting the target to new.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#9
broomy

broomy

    Newbie

  • Members
  • Pip
  • 2 posts

WingedPanther said:

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?

#10
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 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
HTML Links
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#11
Epatron

Epatron

    Learning Programmer

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

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


#12
VakhoQ

VakhoQ

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
nice work :)
GNU/Linux Is the Best.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users