Forum Moderators: open

Message Too Old, No Replies

Custom Pop up Page

         

tomielp

2:24 pm on Jun 5, 2006 (gmt 0)



Hi, how can I popup a new window with a new page in javascript but hiding all default window controls (titlebar, status bar etc) and giving the window a custom appearance with custom "close" button for example.
thanks! Tomas

Fotiman

5:43 pm on Jun 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You really shouldn't do that for usability and accessibility reasons.

rocknbil

6:04 pm on Jun 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard tomielp! :-)

Well, if it's a **supplemental** window, search this site for "Javascript new window". But if you mean to take control of the user's viewport, Very. Bad. Idea.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>New Window</title>
<script type="text/javascript">
function myWin(url) {
var day = new Date();
var id = day.getTime();
var win = open(url,id,'width=550,height=450,scrollbars,resizable');
}
</script>
</head>
<body>
<a href="http://www.example.com" onClick="myWin('http://www.example.com'); return false;">New Win</a>
</body>
</html>

What's happening

The actual href will only execute if Javascript is disabled. If Javascript is enabled, return false wil prevent the current page from going to the link. This allows users to get the content with it on or off.

The URL is passed to the myWin routine as a variable.

The variable "id" is populated with a time value that makes it unique. This insures the content will always open in a new window instead of subsequent click populating the SAME window.

If you remove other controls from your window, always always ALWAYS allow scrollbars and resizing as shown. Although you want to control your presentation, don't ever forget that "what you see" is net very likely what everyone else sees.

To add or remove attributes, you don't need ot include =yes or =no, just add or remove the attribute in the parameter list (there are many more, samle only:)

open(url,id,'width=550,height=450,toolbar,menubar,scrollbars,resizable');