|
首页
|
网页设计
|
w3c标准
|
flash动画
|
平面设计
|
经典文章
|
特约专题
|
资源下载
|
健康频道
|
重庆品牌网站
|
留言簿
|
技术文章
资源下载
经典素材
社区论坛
您现在的位置:
vi设计在线
>>
经典文章
>>
网页设计
>>
技术教程
>> 正文
八种网页弹出窗口网页特效代码
热
[ 作者:佚名 转贴自:本站原创 点击数:3645 更新时间:2007/2/3 文章录入:
QQ392398985
]
减小字体
增大字体
最基本的弹出窗口代码
<SCRIPT LANGUAGE="javascript"> <!-- window.open ('http://www.eqing.com.cn/index.html') --> </SCRIPT>
经过设置后的弹出窗口
<SCRIPT LANGUAGE="javascript"> <!-- window.open ('http://www.eqing.com.cn/index.html', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no') --> </SCRIPT>
用函数控制弹出窗口
下面是一个完整的代码。 <html> <head> <script LANGUAGE="javascript"> <!-- 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="#" onclick="openwin()">打开一个窗口</a> 注意:使用的“#”是虚连接。 方法四:<input type="button" onclick="openwin()" value="打开窗口">
同时弹出2个窗口
对源代码稍微改动一下: <script LANGUAGE="javascript"> <!-- 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)不要相同
主窗口打开文件,同时弹出小窗口
如下代码加入主窗口<head>区: <script language="javascript"> <!-- function openwin() { window.open("page.html","","width=200,height=200") } //--> </script> <body>区加入: <a href="1.htm" onclick="openwin()">open</a> 即可。
弹出的窗口之定时关闭控制
如下代码加入page.html文件的<head>区: <script language="javascript"> function closeit() { setTimeout("self.close()",10000) //毫秒 } </script> 然后,再用<body onload="closeit()">
内包含的弹出窗口-一个页面两个窗口
通过下面的例子,你可以在一个页面内完成上面的效果。 <html> <head> <SCRIPT LANGUAGE="javascript"> 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="#" onclick="openwin()">打开一个窗口</a> <input type="button" onclick="openwin()" value="打开窗口"> </body> </html> 看看 OpenWindow.document.write()里面的代码不就是标准的HTML吗?只要按照格式写更多的行即可。千万注意多一个标签或少一个标签就会出现错误。记得用OpenWindow.document.close()结束啊。
终极应用--弹出的窗口之Cookie控制
将如下代码加入主页面HTML的<HEAD>区: <script> function openwin(){ window.open("page.html","","width=200,height=200") } function get_cookie(Name) { var search = Name + "=" var returnvalue = ""; 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; returnvalue=unescape(documents.cookie.substring(offset, end)) } } return returnvalue; } function loadpopup(){ if (get_cookie('popped')==''){ openwin() documents.cookie="popped=yes" } } </script> 然后,用<body onload="loadpopup()">
上一篇文章:
用Photoshop制作一款古朴逼真的青花瓷器
下一篇文章:
文字在状态栏上从左往右一个一个地显示
【
发表评论
】【
告诉好友
】【
打印此文
】【
关闭窗口
】
技术文章
资源下载
经典素材
社区论坛
中大型美容美发店老…
[
1062
]
重庆多达学习俄语培…
[
2293
]
重庆恒祥广告有限公…
[
1992
]
重庆市南方阻燃电线…
[
2403
]
重庆舞美灯光音响有…
[
3146
]
重庆德鼎滤油机有限…
[
1909
]
重庆民生建材有限公…
[
2351
]
重庆集元科技有限公…
[
4130
]
重庆倍润商贸有限公…
[
2016
]
重庆腾达展览有限公…
[
3082
]
帝一网络创始人宣…
--[
3179
]
重庆vi设计在线祝…
--[
2742
]
重庆帝一网络书生…
--[
2855
]
馋嘴鸭的起伏和经…
--[
3001
]
机器感觉“卡”的…
--[
2930
]
ActionScript3打造…
--[
5766
]
在ASP文件中读取H…
--[
7240
]
vi设计经典案例
--[
63837
]
帅到掉渣-爆笑版勇…
--[
7066
]
一个女孩写的经典…
--[
6827
]
没有相关文章
(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
没有任何评论
|
设为首页
|
加入收藏
|
联系站长
|
友情链接
|
版权申明
|
重庆网站建设
|
版权所有: vi设计在线 © 2005-2018 网站备案序号:渝ICP备06003824号
技术支持:帝一网络(重庆网站建设专家)