Forum Moderators: open
<input name="button" type="button" class="extsite" target="_blank" onClick="parent.location='http://www.externalsite.com'; alert('We are sending you to an external site')" Value="Click to visit the site.">
I tried to make it a regular anchor link but then the Google Toolbar kept blocking the new window as a popup.
I've searched for a solution with no luck. My only thought is I have to create some kind of javascript function to handle this?
Thanks.
You should be able to do what you are after with a regular anchor....
<a href="http://www.externalsite.com" onclick="alert('We are sending you to an external site');window.open('http://www.externalsite.com','external');return false;" title="Opens the external website in a new window">Click to visit the site</a> This will at least enable your users to get to the external site if they have JS disabled (albeit in the same window). If the Google Toolbar is blocking this, then I recon it's going to block every popup - although you can try getting rid of the alert('We are...'); ...?
The window.open() function can take a 3rd parameter which controls the size and gadgets that appear on the popup window, by default it will be just another window with everything.
Popup blockers should not (by default) block popups that are a result of a direct user action, such as clicking on a link.
Using a JS function will not help you in this respect, other than making your code a lot more tidy.
<a href="http://www.externalsite.com" target="_blank" class="ext" onclick="alert('External site')";>CLICK TO Visit External site</a>
I got this to work though:
<a class="activate" target="_blank" href="javascript:alert('Alert text');location.href='http://www.externalsite.com'">Click</a>
Its doesn't work if Javascript is disabled though.
The code you mentioned still gets blocked by the toolbar but thanks anyway.
<form style="margin:0;padding:0;" method="get" action="http://www.example.com" target="new window"><input type="submit" onClick="alert('thanks for visiting!');" value="I'm outta here"></form>
Didn't test against popup blockers, but shouldn't give you grief.
Personally I only use the default popup blockers (on their default settings) that come as part of FF and IE and have no problem with displaying correctly coded popups, and nor am I overrun with annoying popups.
I'm curious, does the following get blocked by your 'Googlebar popup blocker' under IE7...?
<a href="http://www.example.com" onclick="window.open('http://www.example.com','popup');return false;">Click here to popup</a>
and added LinkAlert to it:
<a href="http://www.example.com" onclick="window.open('http://www.example.com','popup');LinkAlert();return false;" >Click here to popup</a>
And that works,but IF I put the LinkAlert before the window.open, Google blocks it.
...but IF I put the LinkAlert before the window.open, Google blocks it.
It looks like the Googlebar is perceiving that the window.open() command is not as a result of a direct user action, with another command (that requires user action) occuring before it - which in a way is correct. Although that doesn't really explain why your method above works OK...?
<a target="_blank" href="javascript:alert('Alert text');location.href='http://www.externalsite.com'">Click</a> Interesting... thanks for testing! :)