jls33fsls
asked on
Restore a minimized windows with Javascript
I create a new window with javascript and I need to be able to restore it from being minimized when a certain action happens on the new window. I tried window.focus(), but that only works on Mac OS X, is there a way to get this to work on Windows?
ASKER
The window isn't being restored, it is only loaded once.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That wouldn't be an option, users want it in its own window.
<html>
<head>
<title>Window Management[Pravin Asar]</title>
<style type="text/css">
input {
width: 50%;
height: 10%;
}
</style>
<script language="javascript">
var sw = null;
function OpenCenWindow (imgURL, winname, width, height) {
var x = 0.5 *(window.screen.width - width);
var y = 0.5 *(window.screen.height - height);
var posStr = ", screenX=" + x + ", screenY=" + y;
if (sw) {
sw.close();
}
if (document.all) {
posStr = ", left=" + x + ", top=" + y;
}
var pStr = 'location=no, resizable=no, status=no,width=' + width + ', height=' + height +
', alwaysRaised=1, addressbar=no, titlebar=no, toolbar=no, menubar=no, status=no';
sw = window.open (imgURL, winname,pStr +posStr );
return sw;
}
function CloseWindow() {
if (sw) { sw.close(); }
sw = null;
}
function RefocusWindow() {
if (sw) { sw.focus(); }
}
function BlurWindow() {
self.focus();
}
</script>
</head>
<body>
<br><input type="button" value="Open New Window" onclick="OpenCenWindow('http://www.yahoo.com','mywin', 400,400);">
<br><input type="button" value="Close Window" onclick="CloseWindow();">
<br><input type="button" value="Loose Focus Window" onclick="BlurWindow();">
<br><input type="button" value="Refocus Window" onclick="RefocusWindow();" >
</body>
</html>
<head>
<title>Window Management[Pravin Asar]</title>
<style type="text/css">
input {
width: 50%;
height: 10%;
}
</style>
<script language="javascript">
var sw = null;
function OpenCenWindow (imgURL, winname, width, height) {
var x = 0.5 *(window.screen.width - width);
var y = 0.5 *(window.screen.height - height);
var posStr = ", screenX=" + x + ", screenY=" + y;
if (sw) {
sw.close();
}
if (document.all) {
posStr = ", left=" + x + ", top=" + y;
}
var pStr = 'location=no, resizable=no, status=no,width=' + width + ', height=' + height +
', alwaysRaised=1, addressbar=no, titlebar=no, toolbar=no, menubar=no, status=no';
sw = window.open (imgURL, winname,pStr +posStr );
return sw;
}
function CloseWindow() {
if (sw) { sw.close(); }
sw = null;
}
function RefocusWindow() {
if (sw) { sw.focus(); }
}
function BlurWindow() {
self.focus();
}
</script>
</head>
<body>
<br><input type="button" value="Open New Window" onclick="OpenCenWindow('http://www.yahoo.com','mywin', 400,400);">
<br><input type="button" value="Close Window" onclick="CloseWindow();">
<br><input type="button" value="Loose Focus Window" onclick="BlurWindow();">
<br><input type="button" value="Refocus Window" onclick="RefocusWindow();"
</body>
</html>
Please change
var pStr = 'location=no, resizable=no, status=no,width=' + width + ', height=' + height +
', alwaysRaised=1, addressbar=no, titlebar=no, toolbar=no, menubar=no, status=no';
to
var pStr = 'location=no,resizable=no, status=no, width=' + width + ',height=' + height +
',alwaysRaised=1,addressba r=no,title bar=no,too lbar=no,me nubar=no,s tatus=no';
since spaces are not allowed in that parm
Also since =1 is not needed and =no is default if one parameter is defined, you can use
var pStr = 'width=' + width + ',height=' + height +',alwaysRaised';
However alwaysRaised is not supported by most browsers and then only if the script is signed so you end up with
var pStr = 'width=' + width + ',height=' + height;
var pStr = 'location=no, resizable=no, status=no,width=' + width + ', height=' + height +
', alwaysRaised=1, addressbar=no, titlebar=no, toolbar=no, menubar=no, status=no';
to
var pStr = 'location=no,resizable=no,
',alwaysRaised=1,addressba
since spaces are not allowed in that parm
Also since =1 is not needed and =no is default if one parameter is defined, you can use
var pStr = 'width=' + width + ',height=' + height +',alwaysRaised';
However alwaysRaised is not supported by most browsers and then only if the script is signed so you end up with
var pStr = 'width=' + width + ',height=' + height;
Accept http:#a24500720
Open in new window