乐府诗个人博客 >> ASP >> JAVASCRIPT的常用技术(三)

JAVASCRIPT的常用技术(三)

真正的全屏页面解决之道!(全代码)  
真正全屏解决之道:  
1.htm  
<html>  
<head>  
<title>无标题文档</title>  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
</head>  
<body onload="window.open('fullscreen.htm','','fullscreen=1,scroll=no');">  
</body>  
</html>  

fullscreen.htm  
<html>  
<head>  
<title>无标题文档</title>  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
<script language="javascript1.2">   
<!--   
function opensmallwin(myurl){   
var w2=300;//想弹出窗口的宽度   
var h2=100;//想弹出窗口的高度   
var w3=window.screen.width/2-w2/2;   
var h3=window.screen.height/2-h2/2;   
window.open(myurl,'small','toolbar=no,location=no,directories=no,status=no,menubar=no,
scrollbars=no,resizable=0,width='+ w2 +',height='+ h2 +',left='+ w3 +',top='+ h3 +'');   
}   
file://-->   
<!--  
function modelesswin(url,mwidth,mheight){  
  if (document.all&&window.print)  
    eval('window.external.m2_blocked(url,"","help:0;resizable:0;status:0;center:1;
scroll:0;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')   
  else  
    eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px,resizable=1,
scrollbars=1")')  
  }  
file://-->  
</script>   
</head>  
<body  scroll="no">  
<div align="right"><a href="javascript:" onclick="window.close()">关闭
</a> </div>  
<p></P>  
<div align="right"><a href="javascript:" onclick="opensmallwin('login.htm')">登录
</a> </div>  
<p></P>  
<div align="center"><a href="javascript:" 
onclick="modelesswin('login.htm',300,160)">用模态登录窗口</a> </div>  
</body>  
</html>  

login.htm  
<html>  
<head>  
<title>用户登录</title>  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
<style type="text/css">  
<!--  
body {  
   background-color: #EAEAEA;  
   font-family: Arial, Helvetica, sans-serif;  
   font-size: 12px;  
   line-height: 24px;  
   color: #336699;  
}  
input.boxline {  
   width: 100px;  
   font-family: "Times New Roman", "Times", "serif";  
   font-size: 9pt;  
   border: 1px solid #669999;  
   height: 18px;  
}  
input.whiteline {    
   font-size: 12px; border: 1px #999999 solid  
}  
-->  
</style></head>  
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">  
<table width="100%" height="100%" border="0" cellpadding="0"
 cellspacing="14" bgcolor="#CCCCCC">  
  <tr valign="top">  
    <td width="10%" nowrap  align="right"><b>用户名:</b></td>  
    <td width="90%"><input name="textfield1" type="text" size="25"
 class="whiteline"></td>  
  </tr>  
  <tr valign="top">  
    <td nowrap align="right"><b>密 码:</b></td>  
    <td><input name="textfield12" type="password" size="25" 
class="whiteline"></td>  
  </tr>  
  <tr valign="top">  
    <td> </td>  
    <td><input type="submit" name="Submit" value="登  录" 
class="boxline"></td>  
  </tr>  
</table>  
</body>  
</html>  

自动关掉原窗口:  

<html>  
<head>  
<title>无标题文档</title>  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
<style type="text/css">  
<!--  
body {  
   margin-left: 0px;  
   margin-top: 0px;  
   margin-right: 0px;  
   margin-bottom: 0px;  
}  
-->  
</style>  
</head>  
<body onload="window.open('fullscreen.htm','','fullscreen=1,scroll=no');
window.opener=null;window.close()">  
<input type=button value=关闭 onclick="window.opener=null;window.close()">   
<!-- IE5.5+ 不会有弹出提示 -->   
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 
height=0 width=0></OBJECT>   
<input type=button value=关闭窗口 onclick=document.all.WebBrowser.ExecWB(45,1)>   
</body>  
</html>  
关键是在onload事件中加入:  
window.opener=null;window.close()  

预读图片: 
<SCRIPT LANGUAGE="javascript"> 
<!-- This script and many more are available free online at --> 
<!-- The javascript Source!! <a href=http://javascript.internet.com 
target=_blank>http://javascript.internet.com --> 
<!-- Begin 
image1 = new Image(); 
image1.src = "image1.gif"; 
image2 = new Image(); 
image2.src = "image2.gif"; 
// End --> 
</script> 
 
关于两个网页刷新交互的问题  
JS处理方法:  
a.htm  
<a href="b.htm" target=blank>发表留言</a>  
<script>  
alert("wwwwwwwwwwwwwwwwwwwwwwwwww");  
</script>  
b.htm  
<script language="javascript">  
file://window.opener.location.reload();刷新父窗口  
file://window.opener.location="2.htm"//重定向父窗口到2.htm页  
function closewindow()  
{  
window.opener.location.reload();  
self.close();  
window.opener.document.write("sssssssssssssssssss");  
}  
</script>  
<a href="b.htm" target=blank onclick="closewindow();">关闭</a>  
 
后台处理方法:  
private btnForSubmit(Object sender,EventArgs e)  
{  
 .............  
 Response.Write("<script>window.opener.document.execCommand('refresh');
window.opener='';window.close();</script>");  
file://string str="<script>window.opener.document.execCommand('refresh');
window.opener='';window.close();</script>";  
file://this.RegisterStartupScript("mycode",str);

下列内容与javascript有着内在的联系,建议您一并阅读。

公益广告