文件說(shuō)明:images/left.gif——左邊的廣告文件 images/right.gif——右邊的廣告文件 images/close1.gif——關(guān)閉
將以下文當(dāng)保存為yiskyindex.js
JavaScript代碼
- GxG1 = '<img src="images/left.gif" width="138" height="297" border="0">';
- GxG2 = '<img src="images/right.gif" width="138" height="297" border="0">';
- Double();
- function Double() {
- document.write('<div id="Gx1" style="left:5px;position:absolute;top:269px;">' + GxG1 +'<br><a href="#"
- onclick="Close();"><img src="images/close1.gif" onClick="javascript:window.hide()" width="69" height="14" border="0"
- vspace="3" alt="關(guān)閉對(duì)聯(lián)廣告"></a></div>');
- document.write('<div id="Gx2" style="right:5px;position:absolute;top:269px;">' + GxG2 +'<br><a href="#"
- onclick="Close();"><img src="images/close1.gif" onClick="javascript:window.hide()" width="69" height="14" border="0"
- vspace="3" alt="關(guān)閉對(duì)聯(lián)廣告"></a></div>');
- var obj1 = document.getElementById('Gx1');
- var obj2 = document.getElementById('Gx2');
- this.Close = function() {
- obj1.style.display = 'none';
- obj2.style.display = 'none';
- };
- var lastScrollY = 0;
- this.Show = function() {
- var diffY;
- if (document.documentElement && document.documentElement.scrollTop) {
- diffY = document.documentElement.scrollTop;
- } else if (document.body) {
- diffY = document.body.scrollTop;
- };
- var percent = .1 * (diffY - lastScrollY);
- if (percent > 0) percent = Math.ceil(percent);
- else percent = Math.floor(percent);
- obj1.style.top = parseInt(obj1.style.top) + percent + "px";
- obj2.style.top = parseInt(obj2.style.top) + percent + "px";
- lastScrollY = lastScrollY + percent;
- };
- window.setInterval("this.Show()", 1);
- };
最后在相關(guān)網(wǎng)頁(yè)中加入<script language=JavaScript src="images/yiskyindex.js"></script>代碼