js学习2

来源:互联网 发布:python turtle 国旗 编辑:程序博客网 时间:2024/04/25 20:18

window.statue = "welcome to my web site!";  //browser status bar
window.open("userhelp.htm","_blank","height=300,width=200,toolbar=no,status=no,menubar=no,location=no");
//the preceding code will open a new browser window and direct it to the HTML file userhelp.htm.
//The code specifies a specific height and width for the window(300 by 200) and removes all
//toolbars,menu bars,and the status bar,leaving a sparse window.

window,resizeTo(640,480);//resize the browser to 640 pixels by 480 pixels tall.
window.moveTo(topLeftX,topLeftY);//reset the browser's location.
history.back().//back to previous web page.
history.go(-5);//send the browser back five pages.the number(-5) can be a positive number or a negative one.
              // a positive number goes forward and a negative one goes back.
history.forward();//go forward one item in the history list;simulates the Forward browser button.
-----------------location abject------------------
property name   purpose                                       example
href            gets or sets the entire URL as a string       location.href="http://www.example.com/another/page.htm";
hash            gets or sets the portion of the URL after the hash sign(#)
host            gets or sets the hostname and port number portion of the URL
hostname        gets or sets the hostname portion of the URL
pathname        gets or sets the filename or path of the web page.
port            gets or sets the port number portion of the URL.
protocal        gets or sets the web protocal name of the URL(e.g.,HTTP).
search          gets or sets the portion of the URL after the question make(?).
Method Name     Purpose
assign          load a new web page.
reload          reloads the existing web page.
replace         replace the existing web page by loading a new web page.
---------------------RGB----------------------------
format: #XXXXXX
the color #FF33C0 represents a combination of bright red,dark green,and medium blue.
#FFFFFF represents pure white , and #000000 represents pure black.
----------------------js------------------
document.getElementsByTagName("input");
document.getElementById("");
document.getElementsByName(""); 
elementId.style.backgroudColor = "black";
elementId.style.color = "white";
elementId.style.font = "22pt Arial";
document.write("");
Array.pop(),Array.push() //similar to a stack
Array.shift(),Array.unshift()//similar to a call queue
cancat(array1,array2,array2...arrayN);//joins two or more arrays into a single array
Array.join(separator) //joins all the elements of an array into a single string ,separated
                //by the separator indicated or a comma if none is specified.
Array.reverse();
Array.slice(begin,end);//creates a new array from a subsection of the existing array.
Array.splice(index,howMany,element1,element2...elementN);//used to add or removed
       //elements from array.
sort(functionName);//used to sort the elements of an array.
new StaticArray[datatype](); ,new StaticArray[datatype](size);new StaticArray();new StaticArray(size);
new ConstArray[](); new ConstArray();
try {
} catch (e) {
 if(isIE) {
  alert(e.description);
 } else {
  alert(e);
 }
}

try {
}
catch () {
}
finally {
}
var i = parseInt("123"); // string to int
var f = parseFloat("123.23");// string to float
Use the IE Error Object
number: a numeric value related to the error.
description: a string describing the error.
var myerr = new Error(100,""); 

原创粉丝点击