Forum Moderators: open
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');