javascript之弹出窗口

来源:互联网 发布:淘宝一键代销怎么设置 编辑:程序博客网 时间:2024/05/09 02:50

父页是显示标题,弹出页修改标题提交后,父页更新:

<script language=javascript>
function winclose() {
window.opener.location.reload();//刷新
window.close();//关闭
}
</script>
<input type=button name=close value="关闭" onclick=winclose()>
<a href=javascript:history.back()><span style="text-decoration: none">返回</span></a>


5 秒后弹窗一个的代码
<script language='javascript'>
var sVarPopWin=true;
function PlayJsAdPopWin()
{
if( sVarPopWin )
{
popwin=window.open("您需要弹的网站地址","","height=300, width=360");
}
}
setTimeout("PlayJsAdPopWin()", 16000 );
</script>

上面的代码中有一句

popwin=window.open("您需要弹的网站地址","","height=300, width=360");

后面的 height=300, width=360 是您需要弹出的页面大小。

如果您想直接弹出网页可以用下面的代码。

<script language='javascript'>
var sVarPopWin=true;
function PlayJsAdPopWin()
{
if( sVarPopWin )
{
popwin=window.open("您需要弹的网站地址","");
}
}
setTimeout("PlayJsAdPopWin()", 16000 );
</script>

超完美弹窗代码
功能:5小时弹一次+背后弹出+自动适应不同分辩率+准全屏显示

代码:
<script>
function openwin(){
window.open(http://www.6882.com,"pop1","width="+(window.screen.width-15)+",height="+(window.screen.height-170)+",left=0,top=0,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,status=yes")
setTimeout("focus();",5);
}
function get_cookie(Name) {
var search = Name + "="
var return&#118alue = "";
if (documents&#46cookie.length > 0) {
offset = documents&#46cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = documents&#46cookie.indexOf(";", offset);
if (end == -1)
end = documents&#46cookie.length;
return&#118alue=unescape(documents&#46cookie.substring(offset, end))
}
}
return return&#118alue;
}
function Set()
{
  var Then = new Date()    
  Then.setTime(Then.getTime() + 5*60*60*1000 )
  documents&#46cookie = "popped1=yes;expires="+ Then.toGMTString()
}

function loadpopup(){
if (get_cookie('popped1')=='')
{
openwin()
Set()
}
}
setTimeout("loadpopup()",5);

</script>


【1、最基本的弹出窗口代码】

其实代码非常简单:

<script language="&#106avascript">
<!--
window.open ('page.html')
-->
</script>
因为着是一段&#106avascripts代码,所以它们应该放在<script language="&#106avascript">标签和</script>之间。<!-- 和 -->是对一些版本低的浏览器起作用,在这些老浏览器中不会将标签中的代码作为文本显示出来。要养成这个好习惯啊。
window.open ('page.html') 用于控制弹出新的窗口page.html,如果page.html不与主窗口在同一路径下,前面应写明路径,绝对路径(http://)和相对路径(../)均可。用单引号和双引号都可以,只是不要混用。
这一段代码可以加入html的任意位置,<head>和</head>之间可以,<body>间</body>也可以,越前越早执行,尤其是页面代码长,又想使页面早点弹出就尽量往前放。


【2、经过设置后的弹出窗口】

下面再说一说弹出窗口的设置。只要再往上面的代码中加一点东西就可以了。
我们来定制这个弹出的窗口的外观,尺寸大小,弹出的位置以适应该页面的具体情况。
<script language="&#106avascript">
<!--
window.open ('page.html', 'newwindow', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
//写成一行
-->
</script>
参数解释:
<script language="&#106avascript"> js脚本开始;
window.open 弹出新窗口的命令;
'page.html' 弹出窗口的文件名;
'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空''代替;
height=100 窗口高度;
width=400 窗口宽度;
top=0 窗口距离屏幕上方的象素值;
left=0 窗口距离屏幕左侧的象素值;
toolbar=no 是否显示工具栏,yes为显示;
menubar,scrollbars 表示菜单栏和滚动栏。
resizable=no 是否允许改变窗口大小,yes为允许;
location=no 是否显示地址栏,yes为允许;
status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;
</script> js脚本结束


【3、用函数控制弹出窗口】

下面是一个完整的代码。
<html>
<head>
<script language="&#106avascript">
<!--
function openwin() { window.open ("page.html", "newwindow", "height=100, width=400, toolbar=
no, menubar=no, scrollbars=no, resizable=no, location=no, status=no"
//写成一行
}
//-->
</script>
</head>
<body onload="openwin()">
...任意的页面内容...
</body>
</html>
这里定义了一个函数openwin(),函数内容就是打开一个窗口。在调用它之前没有任何用途。
怎么调用呢?
方法一:<body onload="openwin()"> 浏览器读页面时弹出窗口;
方法二:<body onunload="openwin()"> 浏览器离开页面时弹出窗口;
方法三:用一个连接调用:
<a href="#" &#111nclick="openwin()">打开一个窗口</a>
注意:使用的“#”是虚连接。
方法四:用一个按钮调用:
<input type="button" &#111nclick="openwin()" &#118alue="打开窗口">

【4、同时弹出2个窗口】

对源代码稍微改动一下:
<script language="&#106avascript">
<!--
function openwin()
{ window.open ("page.html", "newwindow", "height=100, width=100, top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no"
//写成一行
window.open ("page2.html", "newwindow2", "height=100, width=100, top=100, left=100,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no"
//写成一行
}
//-->
</script>
为避免弹出的2个窗口覆盖,用top和left控制一下弹出的位置不要相互覆盖即可。最后用上面说过的四种方法调用即可。

注意:2个窗口的name(newwindows和newwindow2)不要相同,或者干脆全部为空。ok?

【5、主窗口打开文件1.htm,同时弹出小窗口page.html】

如下代码加入主窗口<head>区:
<script language="&#106avascript">
<!--
function openwin()
{window.open("page.html","","width=200,height=200"
}
//-->
</script>
加入<body>区:
<a href="1.htm" &#111nclick="openwin()">open</a>即可。

【6、弹出的窗口之定时关闭控制】

下面我们再对弹出的窗口进行一些控制,效果就更好了。如果我们再将一小段代码加入弹出的页面(注意是加入到page.html的html中,可不是主页面中,否则...),让它10秒后自动关闭是不是更酷了?

首先,将如下代码加入page.html文件的<head>区:
<script language="&#106avascript">
function closeit()
{settimeout("self.close()",10000) //毫秒}
</script>
然后,再用<body onload="closeit()"> 这一句话代替page.html中原有的<body>这一句就可以了。(这一句话千万不要忘记写啊!这一句的作用是调用关闭窗口的代码,10秒钟后就自行关闭该窗口。)

【7、在弹出窗口中加上一个关闭按钮】

<form>
<input type='button' &#118alue='关闭' &#111nclick='window.close()'>
</form>
呵呵,现在更加完美了!

【8、内包含的弹出窗口-一个页面两个窗口】

上面的例子都包含两个窗口,一个是主窗口,另一个是弹出的小窗口。

通过下面的例子,你可以在一个页面内完成上面的效果。
<html>
<head>
<script language="&#106avascript">
function openwin()
{openwindow=window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars="+scroll+",menubar=no";
//写成一行
openwindow.document.write("<title>例子</title>"
openwindow.document.write("<body bgcolor=#ffffff>"
openwindow.document.write("<h1>hello!</h1>"
openwindow.document.write("new window opened!"
openwindow.document.write("</body>"
openwindow.document.write("</html>"
openwindow.document.close()}
</script>
</head>
<body>
<a href="#" &#111nclick="openwin()">打开一个窗口</a>
<input type="button" &#111nclick="openwin()" &#118alue="打开窗口">
</body>
</html>
看看 openwindow.document.write()里面的代码不就是标准的html吗?只要按照格式写更多的行即可。千万注意多一个标签或少一个标签就会出现错误。记得用openwindow.document.close()结束啊。

【9、终极应用--弹出的窗口之cookie控制】

回想一下,上面的弹出窗口虽然酷,但是有一点小毛病(沉浸在喜悦之中,一定没有发现吧?)比如你将上面的脚本放在一个需要频繁经过的页面里(例如首页),那么每次刷新这个页面,窗口都会弹出一次,是不是非常烦人?:-(有解决的办法吗?yes! ;-) follow me.

我们使用cookie来控制一下就可以了。

首先,将如下代码加入主页面html的<head>区:
<script>
function openwin()
{window.open("page.html","","width=200,height=200"}
function get_cookie(name)
{var search = name + "="
var return&#118alue = "";
if (documents&#46cookie.length > 0) {
offset = documents&#46cookie.indexof(search)
if (offset != -1) {
offset += search.length
end = documents&#46cookie.indexof(";", offset);
if (end == -1)
end = documents&#46cookie.length;
return&#118alue=unescape(documents&#46cookie.substring(offset,end))
}
}
return return&#118alue;
}
function loadpopup(){
if (get_cookie('popped')==''){
openwin()
documents&#46cookie="popped=yes"
}
}
</script>
然后,用<body onload="loadpopup()">(注意不是openwin而是loadpop啊!)替换主页面中原有的<body>这一句即可。你可以试着刷新一下这个页面或重新进入该页面,窗口再也不会弹出了。真正的pop-only-once!
强力弹窗代码:

<Script Language="&#106avascript">
var paypopupURL = "http://23sui.com";
var usingActiveX = true;
function blockError(){return true;}
window.&#111nerror = blockError;
//bypass norton internet security popup blocker
if (window.SymRealWinOpen){window.open = SymRealWinOpen;}
if (window.NS_ActualOpen) {window.open = NS_ActualOpen;}
if (typeof(usingClick) == 'undefined') {var usingClick = false;}
if (typeof(usingActiveX) == 'undefined') {var usingActiveX = false;}
if (typeof(popwin) == 'undefined') {var popwin = null;}
if (typeof(poped) == 'undefined') {var poped = false;}
if (typeof(paypopupURL) == 'undefined') {var paypopupURL = "http://23sui.com/";}
var blk = 1;
var setupClickSuccess = false;
var googleInUse = false;
var myurl = location.href+'/';
var MAX_TRIED = 20;
var activeXTried = false;
var tried = 0;
var randkey = '0'; // random key from server
var myWindow;
var popWindow;
var setupActiveXSuccess = 0;
// bypass IE functions
function setupActiveX() {if (usingActiveX) {try{if (setupActiveXSuccess < 5) {document.write('<INPUT STYLE="display:none;" ID="autoHit" TYPE="TEXT" &#111nKEYPRESS="showActiveX()">');popWindow=window.createPopup();popWindow.document.body.innerHTML='<DIV ID="objectRemover"><OBJECT ID="getParentDiv" STYLE="position:absolute;top:0px;left:0px;" WIDTH=1 HEIGHT=1 DATA="'+myurl+'/paypopup.html" TYPE="text/html"></OBJECT></DIV>';document.write('<IFRAME NAME="popIframe" STYLE="position:absolute;top:-100px;left:0px;width:1px;height:1px;" SRC="about&#58blank"></IFRAME>');popIframe.document.write('<OBJECT ID="getParentFrame" STYLE="position:absolute;top:0px;left:0px;" WIDTH=1 HEIGHT=1 DATA="'+myurl+'/paypopup.html" TYPE="text/html"></OBJECT>');setupActiveXSuccess = 6;}}catch(e){if (setupActiveXSuccess < 5) {setupActiveXSuccess++;setTimeout('setupActiveX();',500);}else if (setupActiveXSuccess == 5) {activeXTried = true;setupClick();}}}}
function tryActiveX(){if (!activeXTried && !poped) {if (setupActiveXSuccess == 6 && googleInUse && popWindow && popWindow.document.getElementById('getParentDiv') && popWindow.document.getElementById('getParentDiv').object && popWindow.document.getElementById('getParentDiv').object.parentWindow) {myWindow=popWindow.document.getElementById('getParentDiv').object.parentWindow;}else if (setupActiveXSuccess == 6 && !googleInUse && popIframe && popIframe.getParentFrame && popIframe.getParentFrame.object && popIframe.getParentFrame.object.parentWindow){myWindow=popIframe.getParentFrame.object.parentWindow;popIframe.location.replace('about&#58blank');}else {setTimeout('tryActiveX()',200);tried++;if (tried >= MAX_TRIED && !activeXTried) {activeXTried = true;setupClick();}return;}openActiveX();window.windowFired=true;self.focus();}}
function openActiveX(){if (!activeXTried && !poped) {if (myWindow && window.windowFired){window.windowFired=false;document.getElementById('autoHit').fireEvent("&#111nkeypress",(document.createEventObject().keyCode=escape(randkey).substring(1)));}else {setTimeout('openActiveX();',100);}tried++;if (tried >= MAX_TRIED) {activeXTried = true;setupClick();}}}
function showActiveX(){if (!activeXTried && !poped) {if (googleInUse) {window.daChildObject=popWindow.document.getElementById('objectRemover').children(0);window.daChildObject=popWindow.document.getElementById('objectRemover').removeChild(window.daChildObject);}newWindow=myWindow.open(paypopupURL,'abcdefg');if (newWindow) {newWindow.blur();self.focus();activeXTried = true;poped = true;}else {if (!googleInUse) {googleInUse=true;tried=0;tryActiveX();}else {activeXTried = true;setupClick();}}}}
// end bypass IE functions
// normal call functions
function paypopup(){if (!poped) {if(!usingClick && !usingActiveX) {popwin = window.open(paypopupURL,'abcdefg');if (popwin) {poped = true;}self.focus();}}if (!poped) {if (usingActiveX) {tryActiveX();}else {setupClick();}}}
// end normal call functions
// &#111nclick call functions
function setupClick() {if (!poped && !setupClickSuccess){if (window.Event) document.captureEvents(Event.CLICK);prePaypop&#111nclick = document.&#111nclick;document.&#111nclick = gopop;self.focus();setupClickSuccess=true;}}
function gopop() {if (!poped) {popwin = window.open(paypopupURL,'abcdefg');if (popwin) {poped = true;}self.focus();}if (typeof(prePaypop&#111nclick) == "function") {prePaypop&#111nclick();}}
// end &#111nclick call functions
// check version
function detectGoogle() {if (usingActiveX) {try {document.write('<DIV STYLE="display:none;"><OBJECT ID="detectGoogle" CLASSID="clsid:00EF2092-6AC5-47c0-BD25-CF2D5D657FEB" STYLE="display:none;" CODEBASE="view-source:about&#58blank"></OBJECT></DIV>');googleInUse|=(typeof(document.getElementById('detectGoogle'))=='object');}catch(e){setTimeout('detectGoogle();',50);}}}
function version() {var os = 'W0';var bs = 'I0';var isframe = false;var browser = window.navigator.userAgent;if (browser.indexOf('Win') != -1) {os = 'W1';}if (browser.indexOf("SV1") != -1) {bs = 'I2';}else if (browser.indexOf("Opera") != -1) {bs = "I0";}else if (browser.indexOf("Firefox") != -1) {bs = "I0";}else if (browser.indexOf("Microsoft") != -1 || browser.indexOf("MSIE") != -1) {bs = 'I1';}if (top.location&nbsp;!= this.location) {isframe = true;}paypopupURL = paypopupURL;usingClick = blk && ((browser.indexOf("SV1") != -1) || (browser.indexOf("Opera") != -1) || (browser.indexOf("Firefox") != -1));usingActiveX = blk && (browser.indexOf("SV1") != -1) && !(browser.indexOf("Opera") != -1) && ((browser.indexOf("Microsoft") != -1) || (browser.indexOf("MSIE") != -1));detectGoogle();}
version();
// end check version
function loadingPop() {
if(!usingClick && !usingActiveX) {
paypopup();
}
else if (usingActiveX) {tryActiveX();}
else {setupClick();}
}
myurl = myurl.substring(0, myurl.indexOf('/',8));
if (myurl == '') {myurl = '.';}
setupActiveX();
loadingPop();
self.focus();
</Script>
弹窗代码-24小时每个IP弹1次
<SCRIPT language="&#106avascript">
<!--
function openpopup(){
url="www.7747.info"
window.open(url,"www.7747.info","width=300,height=150,left=400,top=50")
}

function get_cookie(Name) {
var search = Name + "="
var return&#118alue = "";
if (documents&#46cookie.length > 0) {
offset = documents&#46cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = documents&#46cookie.indexOf(";", offset);
if (end == -1)
end = documents&#46cookie.length;
return&#118alue=unescape(documents&#46cookie.substring(offset, end))
}
}
return return&#118alue;
}

function helpor_net(){
if (get_cookie('popped')==''){
openpopup()
documents&#46cookie="popped=yes"
}
}
helpor_net()
//-->
</SCRIPT>


每24小时弹一次的HTML代码
你可以建立一个ads.js,下面就是这个JS文件的代码.把这个文件调用要你需要弹出广告的网页即可

function openpopup(){
document.writeln(" <SCRIPT language=&#106avascript>");
document.writeln("window.open('http://www.netbei.com">http://www.netbei.com')");
document.writeln("</script/>");
}

function get_cookie(Name) {
var search = Name + "="
var return&#118alue = "";
if (documents.cookie.length > 0) {
offset = documents.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = documents.cookie.indexOf(";", offset);
if (end == -1)
end = documents.cookie.length;
return&#118alue=unescape(documents.cookie.substring(offset, end))
}
}
return return&#118alue;
}

function helpor_net(){
if (get_cookie('popped')==''){
openpopup()
documents.cookie="popped=yes"
}
}
helpor_net()

红色部分换成你要弹出广告的URL


10、超级弹窗代码(MYIE也照弹)
<script language="&#106avascript">
focusid=setTimeout("focus();window.showModelessDialog('http://jaymeng.com/bbs/Plug-ins/download/main.asp','','scroll:1;status:0;help:0;resizable:1;dialogWidth:0px;dialogHeight:0px')",0000)
</script>


11、弹出网页窗口全攻略(html/hta)
如何利用网页弹出各种形式的窗口,我想大家大多都是知道些的,但那种多种多样的弹出式窗口是怎么搞出来的,我们今天就来学习一下:
  1.弹启一个全屏窗口

<html>
<body onload="window.open('http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn','example01','fullscreen');">;
<b>www.e3i5.com</b>
</body>
</html>

  2.弹启一个被F11化后的窗口

<html>
<body onload="window.open(''http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn','example02','channelmode');">;
<b>www.e3i5.com</b>
</body>
</html>

  3.弹启一个带有收藏链接工具栏的窗口

<html>
<body onload="window.open('http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn','example03','width=400,height=300,directories');">
<b>www.e3i5.com</b>
</body>
</html>

  4.网页对话框

<html>
<SCRIPT LANGUAGE="&#106avascript">
<!--
showModalDialog('http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn','example04','dialogWidth:400px;dialogHeight:300px;
dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes')
//-->
</SCRIPT>
<b>www.e3i5.com</b>
</body>
</html>

<html>
<SCRIPT LANGUAGE="&#106avascript">
<!--
showModelessDialog('http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn','example05','dialogWidth:400px;dialogHeight:300px;
dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes')
//-->
</SCRIPT>
<b>http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn</b>
</body>
</html>

  showModalDialog()或是showModelessDialog() 来调用网页对话框,至于showModalDialog()与showModelessDialog()的区别,在于showModalDialog()打开的窗口(简称模式窗口),置在父窗口上,必须关闭才能访问父窗口(建议尽量少用,以免招人反感);showModelessDialog()(简称无模式窗口),打开后不必关闭也可访问父窗口打开的窗口。

dialogHeight: iHeight 设置对话框窗口的高度。
dialogWidth: iWidth 设置对话框窗口的宽度。   
dialogLeft: iXPos 设置对话框窗口相对于桌面左上角的left位置。
dialogTop: iYPos 设置对话框窗口相对于桌面左上角的top位置。
center: {yes | no | 1 | 0 } 指定是否将对话框在桌面上居中,默认值是“yes”。
help: {yes | no | 1 | 0 } 指定对话框窗口中是否显示上下文敏感的帮助图标。默认值是“yes”。   
resizable: {yes | no | 1 | 0 } 指定是否对话框窗口大小可变。默认值是“no”。
status: {yes | no | 1 | 0 } 指定对话框窗口是否显示状态栏。对于非模式对话框窗口,默认值是“yes”;对于模式对话框窗口,默认值是 “no”。

5.HTA窗口

  HTA的全名为HTML Application,翻译过来就是HTML应用程序,你只要简单的用.hta为扩展名保存HTML页面就算创建了一个HTA文件,下面我们就用HTA来编个窗口,将以下这段代码保存为.hta文件,然后再用浏览器打开。

<HTML>
<HEAD>
<TITLE>www.e3i5.com</TITLE>
<HTA:APPLICATION ID="oHTA"
APPLICATIONNAME="myApp"
  BORDER="thin"
  BORDERSTYLE="normal"
  CAPTION="yes"
  ICON="filename.ico"
  MAXIMIZEBUTTON="yes"
  MINIMIZEBUTTON="yes"
  SHOWINTASKBAR="no"
  INGLEINSTANCE="no"
  SYSMENU="yes"
  VERSION="1.0"
  WINDOWSTATE="normal" />
</HEAD>
<BODY>
<b>http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn</b>
</BODY>
</HTML>

  有人会发现上面这些代码与平时的html有点不同,多了HTA:APPLICATION标签,这就是关键之处,hta通过它来提供一系列面向应用程序的功能,接下来再讲一讲它的属性(我的头又在发胀)
  APPLICATIONNAME属性(applicationName)
  此属性为设置HTA的名称。
  BORDER属性(border)
  此属性为设置为HTA的窗口边框类型,默认值为 thick。
  它可以设为 thick 指定窗口为粗边框
        dialog window 指定窗口为对话框
        none 指定窗口无边框
        thin 指定窗口为窄边框
  BORDERSTYLE属性(borderStyle)
  此属性为设置HTA窗口的边框格式,默认值为 normal。
  它可以设为
   normal 普通边框格式
   complex 凹凸格式组合边框
   raised 凸出的3D边框
   static 3D边框格式
   sunken 凹进的3D边框
  CAPTION属性(caption)
  此属性为设置HTA窗口是否显示标题栏或标题,默认值为 yes。
  ICON属性(icon)
  此属性为设置应用程序的图标。
  MAXIMIZEBUTTON属性(maximizeButton)
  此属性为设置是否在HTA窗口中显示最大化按钮,默认值为 yes。
  MINIMIZEBUTTON属性(minimizeButton)
  此属性为设置是否在HTA窗口中显示最小化按钮,默认值为 yes。
  SHOWINTASKBAR属性(showInTaskBar)
  此属性为设置是否在任务栏中显示此应用程序,默认值为 yes。
  SINGLEINSTANCE属性(singleInstance)
  此属性为设置是否此应用程序同时只能运行一次。次属性以APPLICATIONNAME属性作为标识,默认值为 no。
  SYSMENU属性(sysMenu)
  此属性为设置是否在HTA窗口中显示系统菜单,默认值为 yes。
  VERSION属性(version)
  此属性为设置应用程序的版本,默认值为空。
  WINDOWSTATE属性(windowState)
  此属性为设置HTA窗口的初始大小,默认值为 normal。
  它可以设为 normal 默认大小
        minmize 最小化
        maximize 最大化
  以上括号中的是在脚本引用的属性。在脚本中以上属性皆为只读属性。此外,在脚本中还可以使用commandLine属性来检索应用程序启动时的参数。
  在HTA中还可以继续使用html中的绝大多数标签、脚本等。


12、每24小时弹一次的HTML代码
你可以建立一个ads.js,下面就是这个JS文件的代码.把这个文件调用要你需要弹出广告的网页即可

function openpopup(){
document.writeln(" <SCRIPT language=&#106avascript>");
document.writeln("window.open('http://www.netbei.com">http://www.netbei.com')");
document.writeln("</script/>");
}

function get_cookie(Name) {
var search = Name + "="
var return&#118alue = "";
if (documents.cookie.length > 0) {
offset = documents.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = documents.cookie.indexOf(";", offset);
if (end == -1)
end = documents.cookie.length;
return&#118alue=unescape(documents.cookie.substring(offset, end))
}
}
return return&#118alue;
}

function helpor_net(){
if (get_cookie('popped')==''){
openpopup()
documents.cookie="popped=yes"
}
}
helpor_net()

换成你要弹出广告的URL.  

原创粉丝点击