用了很多方法,window.location.replace,new open等等都无法屏蔽地址栏和回退键。
而使用fullscreen则把标题也隐藏掉了,很难看。
在开发中发现一个规律,当使用open打开一个窗口,然后再由它打开一个模态窗口,关掉这两个窗口,重新打开窗口(open模式),就没有了后退键了。
准备:
default.htm=>jump.htm=>jump2.htm=>main.aspx
openPage.js
注意:第一次打开窗体的winopen是会否显示地址栏的关键
openPage.js
Code
/*! @file OpenPage.js
* @namespace resource.js.Page
* @brief XXXX
* @version 1.0
* @date 2009/04/22
* @author Design : 斯利民/2009/04/27
* @author Code : 斯利民/2009/04/27
* @author Modify :
* @note Module : Common
*/
function openwin(url) {
var x = this.screen.availHeight - 90;
var y = this.screen.availWidth - 10;
var fullstyle = " status=yes,toolbar=no,resizable=yes,top=0,left=0,fullscreen=0,scrollbars=yes,width=" + y + ",height=" + x + ";";
this.opener = null;
window.open('', '_self');
var date = new Date();
var strTemp = date.valueOf();
var newWindow = window.open(url, 'winName' + strTemp, fullstyle);
if (newWindow == null) {
window.location.href = url;
return window;
}
else {
this.close();
}
return newWindow;
}
function openshowdialog(url, width, height) {
var x = this.screen.availHeight - 90;
var y = this.screen.availWidth - 10;
var left = (y - width) / 2;
var top = (x - height) / 2;
var fullstyle = " status=yes,toolbar=no,resizable=no,top=" + top + ",left=" + left + ",fullscreen=0,width=" + width + ",height=" + height + ";";
var date = new Date();
var strTemp = date.valueOf();
var newWindow = window.open(url, 'winName' + strTemp, fullstyle);
return newWindow;
}
function openshowdialogwithfull(url) {
var x = this.screen.availHeight - 90;
var y = this.screen.availWidth - 10;
var fullstyle = " status=yes,toolbar=no,resizable=no,top=0,left=0,fullscreen=0,width=" + y + ",height=" + x + ";";
var date = new Date();
var strTemp = date.valueOf();
var newWindow = window.open(url, 'winName' + strTemp, fullstyle);
return newWindow;
}
function openshowdialog01(url, width, height) {
var x = this.screen.availHeight - 90;
var y = this.screen.availWidth - 10;
var left = (y - width) / 2;
var top = (x - height) / 2;
var fullstyle = "dialogWidth=" + width + "px;dialogHeight=" + height + "px;status:no;help:no";
var date = new Date();
var strTemp = date.valueOf();
var newWindow = window.showModalDialog(url, window, fullstyle);
return newWindow;
}
function openshowdialog02(url) {
var x = this.screen.availHeight - 90;
var y = this.screen.availWidth - 10;
var fullstyle = "dialogWidth=" + y + "px;dialogHeight=" + x + "px;status:no;help:no";
var date = new Date();
var strTemp = date.valueOf();
var newWindow = window.showModalDialog(url, window, fullstyle);
return newWindow;
}
/*! @file OpenPage.js
* @namespace resource.js.Page
* @brief XXXX
* @version 1.0
* @date 2009/04/22
* @author Design : 斯利民/2009/04/27
* @author Code : 斯利民/2009/04/27
* @author Modify :
* @note Module : Common
*/
function openwin(url) {
var x = this.screen.availHeight - 90;
var y = this.screen.availWidth - 10;
var fullstyle = " status=yes,toolbar=no,resizable=yes,top=0,left=0,fullscreen=0,scrollbars=yes,width=" + y + ",height=" + x + ";";
this.opener = null;
window.open('', '_self');
var date = new Date();
var strTemp = date.valueOf();
var newWindow = window.open(url, 'winName' + strTemp, fullstyle);
if (newWindow == null) {
window.location.href = url;
return window;
}
else {
this.close();
}
return newWindow;
}
function openshowdialog(url, width, height) {
var x = this.screen.availHeight - 90;
var y = this.screen.availWidth - 10;
var left = (y - width) / 2;
var top = (x - height) / 2;
var fullstyle = " status=yes,toolbar=no,resizable=no,top=" + top + ",left=" + left + ",fullscreen=0,width=" + width + ",height=" + height + ";";
var date = new Date();
var strTemp = date.valueOf();
var newWindow = window.open(url, 'winName' + strTemp, fullstyle);
return newWindow;
}
function openshowdialogwithfull(url) {
var x = this.screen.availHeight - 90;
var y = this.screen.availWidth - 10;
var fullstyle = " status=yes,toolbar=no,resizable=no,top=0,left=0,fullscreen=0,width=" + y + ",height=" + x + ";";
var date = new Date();
var strTemp = date.valueOf();
var newWindow = window.open(url, 'winName' + strTemp, fullstyle);
return newWindow;
}
function openshowdialog01(url, width, height) {
var x = this.screen.availHeight - 90;
var y = this.screen.availWidth - 10;
var left = (y - width) / 2;
var top = (x - height) / 2;
var fullstyle = "dialogWidth=" + width + "px;dialogHeight=" + height + "px;status:no;help:no";
var date = new Date();
var strTemp = date.valueOf();
var newWindow = window.showModalDialog(url, window, fullstyle);
return newWindow;
}
function openshowdialog02(url) {
var x = this.screen.availHeight - 90;
var y = this.screen.availWidth - 10;
var fullstyle = "dialogWidth=" + y + "px;dialogHeight=" + x + "px;status:no;help:no";
var date = new Date();
var strTemp = date.valueOf();
var newWindow = window.showModalDialog(url, window, fullstyle);
return newWindow;
}
default.htm
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>XXXX</title>
<script src="resource/js/Page/OpenPage.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
var nv = navigator.appVersion;
if (nv.indexOf("MSIE 7.0") > -1) {
openwin("Jump.htm");
}
else {
openwin("main.aspx");
}
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>XXXX</title>
<script src="resource/js/Page/OpenPage.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
var nv = navigator.appVersion;
if (nv.indexOf("MSIE 7.0") > -1) {
openwin("Jump.htm");
}
else {
openwin("main.aspx");
}
</script>
</head>
<body>
</body>
</html>
jump.htm
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<script src="resource/js/Page/OpenPage.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
openshowdialog01("Jump2.htm", 10, 10);
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<script src="resource/js/Page/OpenPage.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
openshowdialog01("Jump2.htm", 10, 10);
</script>
</head>
<body>
</body>
</html>
jump2.htm
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<script src="resource/js/Page/OpenPage.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
var y = this.screen.availHeight - 90;
var x = this.screen.availWidth - 10;
var offsetleft = (x - 600) / 2;
var offsettop = (y - 400) / 2;
var win = window.dialogArguments;
self.close();
win.close();
offsettop = 0;
offsetleft = 0;
win.open("main.aspx", "", "toolbar=no,menubar=no,width=" + x + ",height=" + y + ",scrollbars=no,top = " + offsettop + ",left=" + offsetleft + ",resizable=no,location=no,status=yes");
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<script src="resource/js/Page/OpenPage.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
var y = this.screen.availHeight - 90;
var x = this.screen.availWidth - 10;
var offsetleft = (x - 600) / 2;
var offsettop = (y - 400) / 2;
var win = window.dialogArguments;
self.close();
win.close();
offsettop = 0;
offsetleft = 0;
win.open("main.aspx", "", "toolbar=no,menubar=no,width=" + x + ",height=" + y + ",scrollbars=no,top = " + offsettop + ",left=" + offsetleft + ",resizable=no,location=no,status=yes");
</script>
</head>
<body>
</body>
</html>