Forum Moderators: open
<html>
<body>
<a href="test2.html" target="_blank" onclick="alert('Blah')">
Click
</a>
</body>
</html>
When the user clicks the link, he gets the "Blah" alert window. However, when he clicks the OK button, he gets a beep and nothing more.
Both <a href="test2.html" target="_blank"> and <a href="test2.html" onclick="alert('Blah')"> work as one would expect. However, combining the two options will not.
Any ideas?
The function "alert()" should return 1 (to say 'I took care of it, don't take the HREF link') or 0 (to say 'now do the HREF link, please').
Obviously alert() returns what it returns; so you may need to wrap it in your own function:
function myalert() {
alert("blah");
return 0;
}
This is from memory; I may have the values reversed.
<a href="hans2.html" onclick="alert('Blah');return true;">
presents the alert message, then displays hans2.html in the current browser. It is only when the TARGET attribute is added that it fails to work.
However,
<a href="hans2.html" target="_blank">
displays hans2.html in a new browser, but fails when the ONCLICK is added. So it seems that each part of this works correctly until they are used together.
<a href="hans2.html" target="_blank" onmousedown="alert('Blah');">
Click
</a>
This not only doesn't work on the computer in question, but it also fails to do anything after the alert on computers which worked fine using onclick. They now display the alert, then nothing. Suspecting that onmousedown was preventing the click action from occuring, I tried also onmouseup, which produced the same lack of action.
<a href="http://wap.google.com" target="_blank" onclick="alert('Blah');return true;">
Click
</a>
...and it worked just fine.
<a href="http://wap.google.com" target="_blank" onblur="alert('Blah');return true;">
Click
</a>
Also worked, but then the alert pops up behind the new window.
I am using the onMouseOver and onClick commands in conjunction with CSS, to convert a table into icons, but am having a helluva time getting the links to open in a seperate frame.
<TR>
<TD BGCOLOR="#DEDFDF" VALIGN=MIDDLE ALIGN=LEFT WIDTH=110 onMouseover="this.style.backgroundColor='#C6C5D3'; this.style.cursor='hand';" onMouseout="this.style.backgroundColor='#DEDFDF'" onclick="window.location.href='ranges.htm' TARGET='main'"> <FONT SIZE=-2 COLOR="#7667A6"><DD>Ranges</TD>
</TR>
Here's a link to our corporate website, so you can see what I'm attempting to do... [castlestove.com...]