窗口/框架与导航条设计

1.1弹出窗口控制

001打开新窗口显示广告信息

WindowVar=window.open(url,windowname[,localtion]);

举一反三:开发大型门户网站,商务网站,信息资讯网站弹出公告或广告窗口

002定是打开窗口

function pp(){

window.open(“new.html”,”new”,”弹出窗口位置”);

}

setTimeout(“pp()”,5000);     //1000ms等于1s,可以用clearTimeout()函数清除

注意:setTimeout()方法在超时时间后只能调用一次函数,而setInterval()方法是按一定时间重复调用的指定函数

举一反三:开发新闻系统中的即时新闻,热点新闻,电子商务系统中的商品展示,在线论坛中的主题信息浏览

003通过按钮创建窗口

oncllick事件

004自动关闭的广告窗口

在弹出的窗口通过window对象的setTimeout()方法

<body οnlοad=”window.setTimeout(‘window.close()’,5000)”>

005弹出窗口居中显示

function manage(){

var hdc=window.open(‘xxx.html’,’width=322px,height=206px’);

width=screen.width;

height=screen.width;

hdc.moveTo((width-322)/2,(height-206)/2);

}

006弹出窗口之cookie控制

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>无标题文档</title>

<script>

window.moveTo(x,y);

function openWindow(){

 window.open("new.html","","width=352","height=193");

}

function GetCookie(name){

var search=name +"=";

var returnvalue="";

var offset,end;

if(document.cookie.length>0){

offset=document.cookie.indexOf(search);

if(offset!=-1){

offset+=search.length;

end=document.cookie.indexOf(";",offset);

if(end==-1)

end=document.cookie.length;

returnvalue=unespace(document.cookie.substring(offset,end));

}

}

return returnvalue;

}

function LoadPop(){

if(GetCookie("pop")==""){

openWindow();

var today=new Date();

var time="Sunday,1-jan-"+today.getYear()+1+"23:59:59GMC";

document.cookie="pop=yes;expires="+time;

}

}

 

</script>

</head>

 

<body onLoad="LoadPop()">

<h1>欢迎来到javascript</h1>

</body>

</html>

new.html

<body>

啦啦啦啦啦了

</body>

举一反三

1. 开发游戏网站中的系统公告

2. 新闻资讯类网站中的最新公告

3. 大型门户类网站的弹出广告

007.为弹出的窗口添加关闭按钮

window对象的clsoe()方法实现

<body>

欢迎来到<a href="#" onClick="Javascript:window.open("new.html","","width=400","height=220")">javascript</a>

</body>

new.html

<body>

<input type="button" name="Button" value="关闭" onClick="window.close()">

</body>

008关闭弹出窗口时刷新父窗口

语法:

window.opener.语法/属性

实验过程:

<body>

欢迎来到<a href="#" onClick="Javascript:window.open('new.html','','width=400,height=220')">javascript</a>

</body>

new.html

<body>

<input type="submit" name="Submit" value="关闭" onClick="Mycheck()">

<script language="javascript">

function Mycheck(){

alert("关闭子窗口!!");

window.opener.location.reload();

//刷新父窗口的网页

window.close();

//关闭当前窗口

}

</script>

</body>

 

举一反三

1. 办公自动化系统中,打开新的页面添加员工信息后,关闭该页面是、时需要刷新父窗口

2. 添加,修改,删除信息时

009关闭IE主窗口时,不弹出询问对话框

<a href="#" onClick="window.opener=null;window.close();">关闭系统</a>

1.2弹出网页对话框

010弹出网页模式对话框

window对象的showModalDialog()方法,语法格式:

variant=object. showModalDialog(sURL[,vArauments[,sFeatures]])

sURL:制定URL文件地址

vArauments:用于向网页传递参数,传递参数的类型不限制,对于字符串类型

sFeatures:可选项,窗口对话框的设置参数具体有表

实现过程:

<a href="#" onClick="opendialog();">登记</a>

<script>

function opendialog(){

var someValue=window.showModalDialog("new.html","","dialogWidth=640px;dialogHeight=423px;status=no;help=no;scrollbars=no");

}

</script>


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值