当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 让弹出窗口变得“体贴”一些(javascript)

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 让弹出窗口变得“体贴”一些(javascript)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 346 ::
收藏到网摘: n/a

让弹出窗口变得“体贴”一些

  在网上冲浪时进入一些网站会出现弹出窗口。它可能是站长对你的亲切问候,也可能是网站的重要通告、网站广告之类的。但用得不好会让人产生厌烦心理。如何才能让弹出窗口发挥作用,而又不影响浏览者浏览页面呢?

  一般的弹出窗口都需要你去关闭它,浏览者一定会觉得很麻烦。如果能让它自己关闭那该多好。要实现这种效果其实很简单,


1、首先,把下面的程序加入到< head >< /head >区域中。


< script language="JavaScript" >
< !--
var gt = unescape('3e');
var popup = null;
var over = "Launch Pop-up Navigator";
popup = window.open('', 'popupnav', 'width=225,height=235,resizable=1,scrollbars=auto');
if (popup != null) {
if (popup.opener == null) {
popup.opener = self;
}
popup.location.href = 'dogQ.htm';
}
// -- >
< /script >


2、新建dogQ.htm文件(即:弹出窗口所用的文件),此文件名要与上文“popup.location.href = 'dogQ.htm'”中设置的文件名一致。

3、编辑新建的文件dogQ.htm(注意dogQ.htm要与主页面文件在同一目录下)。先把< body bgcolor="#FFFFFF" text="#000000" >改为< body bgcolor="#fef4d9" onload="closeit()" >,然后在< body >< /body >之间加入:


< script language="JavaScript" >
function closeit() {
setTimeout("self.close()",10000)
}
< /script >

  注:倒数第三行中的10000是指过多长时间关闭(可根据需要修改),10000为10秒。这样,弹出窗口在10秒后会自动关闭,浏览者不需要理它。