展开式的弹出窗口
网页上的弹出窗口见得多了,但是没有什么很新颖的效果来显示其过程。你学完这个实例后你就会感觉并不是那么回事,可让你的弹出窗口也活动起来。
制作方法:
将下面的代码复制到<head>~</head>里:
复制内容到剪贴板
代码:
- <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;">
- 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;">
- 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;">
- 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;">
- 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;">
- 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;">
- 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;">
- 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;">
- 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;">
- 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;">
- 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;">
- }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- 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;">
- 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;">
- }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- 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;">
- }<wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;"><wbr style="margin-right: auto; margin-left: auto;">
- </script>
复制代码
将下面的代码复制到<body>~</body>里:
复制内容到剪贴板
代码:
- <a href="javascript:expandingWindow('/html/')">HTML特效</a>
复制代码
如何设置弹出窗口的大小:
本实例中默认的弹出窗口是全屏的大小,可能在制作过程并不需要这么大,所以您可以看看下面的方法具体来修改成您所需的大小,将第一步中的javascript中的:
- var winwidth = window.screen.availWidth - leftdist;
- var winheight = window.screen.availHeight - topdist;
复制代码
改成:
- var winwidth = 300; //300为弹出窗口的宽度
- var winheight = 500; //500为弹出窗口的高度
复制代码
|