mikebai.com

  • Home
  • dev
  • DotNET
  • M365
  • 搞笑
  • 杂七杂八
  • FocusDict
個人BLOG
it developer
  1. Main page
  2. DotNET
  3. Main content

window.open相关

2010-06-01 103hotness 0likes 0comments

http://dev.firnow.com/course/1_web/javascript/jsjs/200855/113518.html


window.open
文章出处:飞诺网(www.firnow.com):http://dev.firnow.com/course/1_web/javascript/jsjs/200855/113518.html


 


if   (xxx   &&   xxx.open   &&   !xxx.closed)
{
//页面已经打开~~~~
}
else
{
        xxx   =   window.open....
}


 


<script>
var   xxx;
function   clickHref()
{

if   (xxx   &&   xxx.open   &&   !xxx.closed)
{
return;
}
xxx   =   window.open( "2.htm ");
document.all.aaa.style.display   =   "none ";
}

function   ajax()
{
//取信息状态
.............

if   (xxx   &&   xxx.open   &&   !xxx.closed)
{
//隐藏信息
document.all.aaa.style.display   =   "none ";
}
else
{
//显示新信息
document.all.aaa.style.display   =   " ";
}
setInterval( 'ajax() ',1000);
}
</script>
<form   id= "form1 "   onload= "ajax() ">
<a   name= "aaa "   href= "# "   onclick= "clickHref() "   target= "_self "> 信息 </a>
</form>


 


 


 


 


 


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>打开指定URL的窗口/改变链接时候状态栏的文字</title>
<script language="javascript">
//申明一个代表窗体对象的变量,这是关键,他作为全局变量,后面两个函数都可以访问他
var SunWindows;
function newWindow(url)
{//这里申明一个根据传来的地址打开新窗口的函数
 if   (SunWindows&&SunWindows.open&&SunWindows.closed)
 {
  return;
 }
    SunWindows=window.open(url,"","width=400,height=300,left=200,top=200");//将打开的窗口对象作为值赋给SunWindows对象
}
function closeWind()
{
    //关闭打开的新窗口,否则提示
    if(SunWindows)//如果SunWindows对象存在
    {
        SunWindows.close();//调用关闭方法
        SunWindows=null//并把值赋成null
    }
    else
    {
        //alert("没有打开的窗口");
    }
}
</script>
</head>


<body onunload="closeWind();">
<p>
  <input type="submit" name="tijiao" value="打开fengyan博客" onclick="newWindow('http://eflylab.cnblogs.com')" />
  打开博客后,关闭本窗体。打开的子窗体会自动关闭
</p>
<p>
  <input type="submit" name="close" value="直接在本窗体中关闭刚才打开的窗口" onclick="closeWind()" />
</p>
<p><a href="http://eflylab.cnblogs.com" >http://eflylab.cnblogs.com</p>
</body>
</html>


http://www.cnblogs.com/eflylab/archive/2008/06/06/1215166.html
 


Definition and Usage
定义与用法


The onunload event occurs when a user exits a page.
当用户关闭一个页面时触发 onunload 事件。


Syntax
语法






onunload="SomeJavaScriptCode"
onunload="所要执行的脚本"









Parameter
参数
Description
描述
SomeJavaScriptCode
JavaScript脚本
Required. Specifies a JavaScript to be executed when the event occurs.
必选项目。当事件被触发

Tag: Nothing
Last updated:2010-06-01

mikebai

This person is a lazy dog and has left nothing

Like
< Last article
Next article >

COPYRIGHT © 2025 mikebai.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang