<script>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>
以下给出了一个例子,可以自定义一个对象。为其添加属性,添加相关的方法。
自己编写这样一个文件(User.js):
- functionUser(name,age){
- //成员变量
- this.name=name;
- this.age=age;
- //成员方法
- this.getName=function(){
- returnthis.name;
- };
- this.getAge=function(){
- returnthis.age;
- };
- this.setName=function(name){
- this.name=name;
- };
- this.setAge=function(age){
- this.age=age;
- };
- }
- functionmain(){
- varuser=newUser("name111",18);
- document.writeln("firname="+user.getName());
- document.writeln("firage="+user.getAge());
- document.writeln("<br><br>");
- user.setAge(20);
- user.setName("newname222222");
- document.writeln("firname="+user.getName());
- document.writeln("firage="+user.getAge());
- }
自己定义了一个User类,添加类的属性和方法。并通过main函数进行测试调用。