流量变现70%分成 全国楼凤小姐姐 招商联系客服 招商联系客服 招商联系客服 招商联系客服

各种页面常用的弹窗代码大全-展开式的弹出窗口

[复制链接]
查看177 | 回复0 | 2024-9-23 12:47:34 | 显示全部楼层 |阅读模式
展开式的弹出窗口



网页上的弹出窗口见得多了,但是没有什么很新颖的效果来显示其过程。你学完这个实例后你就会感觉并不是那么回事,可让你的弹出窗口也活动起来。
制作方法:
将下面的代码复制到<head>~</head>里:
复制内容到剪贴板
代码:
  1. <script language=javascript><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  2. function expandingWindow(website) {<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  3. var heightspeed = 2; // vertical scrolling speed (higher = slower)<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  4. var widthspeed = 7; // horizontal scrolling speed (higher = slower)<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  5. var leftdist = 0; // distance to left edge of window<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  6. var topdist = 0; // distance to top edge of window<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  7. var winwidth = window.screen.availWidth - leftdist;<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  8. var winheight = window.screen.availHeight - topdist;<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  9. var sizer = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=200,height=200,scrollbars=yes");<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  10. for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) {<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  11. sizer.resizeTo("1", sizeheight);<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  12. }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  13. for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) {<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  14. sizer.resizeTo(sizewidth, sizeheight);<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  15. }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  16. sizer.location = website;<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  17. }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
  18. </script>
复制代码

将下面的代码复制到<body>~</body>里:
复制内容到剪贴板
代码:
  1. <a href="javascript:expandingWindow('/html/')">HTML特效</a>
复制代码

如何设置弹出窗口的大小:
本实例中默认的弹出窗口是全屏的大小,可能在制作过程并不需要这么大,所以您可以看看下面的方法具体来修改成您所需的大小,将第一步中的javascript中的:
  1. var winwidth = window.screen.availWidth - leftdist;
  2. var winheight = window.screen.availHeight - topdist;
复制代码

改成:
  1. var winwidth = 300;   //300为弹出窗口的宽度
  2. var winheight = 500;    //500为弹出窗口的高度
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则