Connecting Tech Pros Worldwide Help | Site Map

Add two script commands to the same HREF

Newbie
 
Join Date: Apr 2007
Posts: 21
#1: Dec 8 '07
Hi guys

I recently added a popup HREF script to a page, but I'd also like to make the page itself change when the HREF command is clicked. When the user clicks, not only would the popup window appear, but the originating page would change to another as well.

I thought it'd be a rather straightforward proposition, but I can't seem to get the syntax right. I tried using onClick and adding the second command after a semicolon, neither of which worked.

First, here's the HREF as it now appears:
<A HREF="javascript:newWindow4('play/ep01a.html')" onMouseOver="window.status='popup'; return true" onMouseOut="window.status=''; return true">

You'll notice that it calls an external script variable (newWindow4) which defines the nature of the popup.

Here are a couple of things I unsuccessfully tried to make the page change as well:
<A HREF="javascript:newWindow4('play/ep01a.html')" onClick="location.href='ep01.html'" onMouseOver="window.status='popup'; return true" onMouseOut="window.status=''; return true">

<A HREF="javascript:newWindow4('play/ep01a.html');window.location = "ep01.html"" STYLE="text-decoration: none" onMouseOver="window.status='popup'; return true" onMouseOut="window.status=''; return true">

Neither allows even the original script to run.

Basically, here' what I want it to do:
run newWindow4
change page to ep01.html

Any idea how I can make this link work?

Wolfman
Familiar Sight
 
Join Date: Feb 2007
Posts: 207
#2: Dec 9 '07

re: Add two script commands to the same HREF


Quote:

Originally Posted by Wolfman

Hi guys

I recently added a popup HREF script to a page, but I'd also like to make the page itself change when the HREF command is clicked. When the user clicks, not only would the popup window appear, but the originating page would change to another as well.

No matter how often you see it, script does not belong in the HREF parameter.

Expand|Select|Wrap|Line Numbers
  1. <a href='#' onclick='window.open("http://google.com","xxx","width=300,height=300");location.href="http://youtube.com"'>GO</a>
  2.  
Newbie
 
Join Date: Apr 2007
Posts: 21
#3: Dec 10 '07

re: Add two script commands to the same HREF


Thanks much! I was able to succesfully combine the existing script with your syntax to result in the following line:

<A HREF="javascript:newWindow4('play/ep01a.html');location.href='ep01.html'" onMouseOver="window.status='popup'; return true" onMouseOut="window.status=''; return true">

It worked like a charm and allowed me to avoid a page refresh.

Wolfman
Reply