Javascript中对象的基本用法
声明:
function person(name, country)
{
this.name = name;
this.country = country;
}
实例化对象:
var theauthor = new person('Daniel', 'U.S.A.');
引用:
function sayHello(objPerson)
{
return "Hello " + objPerson.name;
}
document.write( sayHello(theauthor) );
相关文档:
<script>
function getCookieVal(offset) {
var endstr = document.cookie.indexOf(";",offset);
if(endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset,endstr));
}
function FixCookieDate(data) {
var ba ......
需要引入jquery-1.3.2.js
获取宽度
function getCurrentWidth(){
var currentWidth = 0;
// handle IE 6
if ($.browser.msie && $.browser.version < 7) {
var scrollWidth = Math.max(
document.documentElement.scrollWidth,
docu ......
转自:http://www.cnblogs.com/greki/archive/2009/06/02/1494863.html
其它方式:工厂方式,构造函数方式,原型方式都各有各的大缺陷,这里就不一一介绍了,想了解的可以去看一下这本著作的第3章节。
1. 混合构造函数/原型方式
function Car(sColor, iDoors, iMpg) {
this .color = sColor;
this ......
JavaScript是一种通用的、基于原型的、面向对象的脚本语言,而脚本语言就是指可以和Html语言混合使用的语言
1.JavaScript与Java的区别
A. JavaScript是解释型的语言,当程序执行的时候,浏览器一边解释一边执行。而Java是编译型的语言,必须经过编译才能执行
B. 代码 ......
window对象:每一个该对象代表一个浏览器窗口
1.常用方法如下
open("要打开的页面文件名","打开窗口在操作系统中的名称(任何名称都可以)",
"toolbar=?,menubar=?,top=?,left=?,width=?,height=?" ......