Quantcast
Channel: Andrew Gunn's Blog
Viewing all articles
Browse latest Browse all 26

JavaScript - Anchor popups

$
0
0
If JavaScript is disabled, the user will be redirected to whatever is in the href attribute in a new frame. If JavaScript is enabled, a new window will open with the same content but the parent window will stay at it's current location.

JavaScript:
function Popup( url, height, width )
{
var windowProperties = "toolbar = 0, scrollbars = 1, location = 0, statusbar = 0, menubar = 0, resizable = 1, width = " + width + ", height = " + height + ", left = 50, top = 50";

return window.open( url, "", windowProperties );
}


HTML:
<a href="http://www.google.com/" onclick="javascript:Popup( 'http://www.google.com/', 600, 600 ); return false;" target="_blank">Test</a>

The morale of the story is always have a backup for users with JavaScript disabled.

Viewing all articles
Browse latest Browse all 26

Latest Images

Trending Articles





Latest Images