JavaScript教程:JS中创建新对象范例
new_toc_item ("1",2,120,20); <!-- Begin function bannerObject(p){ this.msg = MESSAGE this.out = " " this.pos = POSITION this.delay = DELAY this.i = 0 this.reset = clearMessage} function clearMessage(){ this.pos = POSITION} var POSITION = 50; var DELAY = 150; var MESSAGE = "这是一个动态JavaScript文字显示的例子"; var scroll = new bannerObject(); function scroller(){ scroll.out += " "; if(scroll.pos>0) for (scroll.i = 0; scroll.i < scroll.pos; scroll.i++) { scroll.out +=" " ; } if (scroll.pos>= 0) scroll.out += scroll.msg else scroll.out = scroll.msg.substring(-scroll.pos,scroll.msg.length) document.noticeForm.notice.value = scroll.out scroll.out = " "; scroll.pos--; scroll.pos--; if (scroll.pos < -(scroll.msg.length)) { scroll.reset(); } setTimeout (''scroller()'',scroll.delay);} </script> </head> <body onload="scroller()" bgcolor="#000000" link="#C0C0C0" vlink="#C0C0C0" alink="#008080" text="#C0C0C0"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="100%"><form NAME="noticeForm"> <p><input TYPE="text" name="notice" size="40" style="background-color: rgb(192,192,192)"></p> </form> </td> </tr> </table> </center></div> </body> </html> 范例2:颜色变化的例子。 test5_2.htm <html> <head> <script> <!-- function makearray(n) { this.length = n; for(var i = 1; i <= n; i++) this[i] = 0; return this;} hexa = new makearray(16); for(var i = 0; i < 10; i++) hexa[i] = i; hexa[10]="a"; hexa[11]="b"; hexa[12]="c"; hexa[13]="d"; hexa[14]="e"; hexa[15]="f"; function hex(i) { if (i < 0) ret |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |