Showing posts with label popup. Show all posts
Showing posts with label popup. Show all posts

Wednesday, 3 September 2008

JavaScript - Anchor popups

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.

Tuesday, 1 April 2008

JavaScript - Popup windows

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

function PopupScale( url, scale )
{
// Default sizes.
var height = 800;
var width = 800;

if ( window.screen )
{
height = window.screen.availHeight * scale / 100;
width = window.screen.availWidth * scale / 100;
}

Popup( url, height, width );
}

Example: