1、检查浏览器及版本
function browserVersion(){
//浏览器名称
var browser = navigator.appName;
//浏览器版本
var version = navigator.appVersion;
alert(browser + ";" + version);
}
2、检查浏览器更多信息
function browserVersion(){
//浏览器
var browser = navigator.appName;
//浏览器版本
var version = navigator.appVersion;
//代码
var appCodeName = navigator.appCodeName;
//平台
var platform = navigator.platform;
//启用
var cookieEnabled = navigator.cookieEnabled;
//浏览器的用户代理报头
var userAgent = navigator.userAgent;
}
3、创建对象的实例
function showObject(){
personObj = new Object();
personObj.firstname = "John";
personObj.lastname = "Adams";
personObj.age = 35;
personObj.eyecolor = "black";
alert(personObj.firstname + " 的年龄是 " + personObj.age + " 岁。" );
}
4、利用对象模板创建实例
function person(firstname, lastname, age, eyecolor){
this.firstname = firstname;
this.lastname = lastname;
this.age = age;
this.eyecolor = eyecolor;
}
function showPersonSample(){
myFather = new person("John", "Adams", 35, "black");
alert(myFather.firstname + " 的年龄是 " + myFather.age + "岁。");
}