Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JavaScriptÖеĶÔÏó

JavaScriptÖеĶÔÏó
¹Ø¼ü´Ê£º JavaScript    ¶ÔÏó                                          
´´½¨¶ÔÏóµÄ·½Ê½£º
1£® newÔËËã·û
var o = new Object();//´´½¨Ò»¸ö¿Õ¶ÔÏ󣨼´Ã»ÓÐÈκÎÊôÐԵĶÔÏó£©;
var now = new Date(); //´´½¨µ±Ç°µÄÈÕÆÚºÍʱ¼ä¡£
var new_years_eve = new Date(2000,12,31); //´´½¨2000Äê12ÔÂ31ÈÕ
2£® ¶ÔÏóÖ±½ÓÁ¿
´óÀ¨ºÅÀï ÊôÐÔ:ÊôÐÔÖµ¹¹³É¡£
var empty = {} //´´½¨Ò»¸öûÓÐÊôÐԵĶÔÏó¡£
var point = {x:0,y:0};
var circle = {x:point.x, y:point.y, radius:2};
var homer = {
name:”Homer Simpson”,
age:34,
married:true,
occupation:”plant operator”,
email:”homer@example.com”
}
 
 
¹¹Ô캯Êý£º
ÓÉnewÔËËã·ûµ÷Óã¬new ²Ù×÷·ûÏÈ´´½¨Ò»¸ö¿Õ¶ÔÏó£¬È»ºó½«¸Ã¶ÔÏó×÷Ϊ¹¹Ô캯ÊýµÄthisÖµ£¬²¢µ÷Óù¹Ô캯ÊýÀ´³õʼ»¯Õâ¸ö¶ÔÏó¡££¨¾ßÌå¼ûÔ­Ðͽڣ©
ʵÀý£º
// ¶¨ÒåÒ»¸ö¹¹Ô캯Êý£¬×¢ÒâÔõÑùͨ¹ý”this”ÒýÓÃÀ´³õʼ»¯¶ÔÏóµÄ¡£
function Rectangle(w, h) {
this.width = w;
this.height = h;
}
// µ÷Óù¹Ô캯Êý´´½¨Á½¸ö¶ÔÏó¡£
var rect1 = new Rectangle(2, 4); // rect1 = { width:2, height:4 };
var rect2 = new Rectangle(8.5, 11); // rect2 = { width:8.5, height:11 };
 
 
¶ÔÏóµÄÊôÐÔ£º
ÊôÐԵķÃÎÊ£ºÓÓÒýÓöÔÏó.ÊôÐÔ”·½Ê½¡£ÀýÈço.p£¨·ÃÎÊÒýÓöÔÏóoµÄÊôÐÔp£©¡£Àý×Ó£º
var book = {}; //ÓöÔÏóÖ±½ÓÁ¿µÄ·½Ê½ÉùÃ÷Ò»¸ö¶ÔÏó¡£
book.title = “javascript: The Definitive Guide"; //ÉèÖÃÒ»¸öÊôÐÔ¡£
book.chapter1 = new Object(); //ÉèÖÃÒ»¸öÊôÐÔ£¬¸ÃÊôÐÔÒýÓÃÁËÁíÒ»¸ö¶ÔÏó¡£
book.chapter1.title = “Introduction to JavaScript”; //ÉèÖÃÒ»¸öÊôÐÔ£¨Ç¶Ì׵ĶÔÏ󣩵ÄÊôÐÔ
book.chapter1.pages = 11;
book.chapter2 = {title: "Lexical Structure", pages: 6} //¶ÔÏóÖ±½ÓÁ¿µÄ·½Ê½£¬ÉùÃ÷Ò»¸öÊôÐÔ
alert("Outline: " + book.title + "\n\t" + //¶ÁÈ¡ÊôÐÔÖµ
"Chapter 1 " + book.chapter1.title + "\n\t" +
"Chapter 2 " + book.chapter2.title);
×¢Ò⣺¿ÉÒÔͨ¹ý°ÑÒ»¸öÖµ¸³


Ïà¹ØÎĵµ£º

javascript ÏÂÀ­¿ò£¨select)Ñ¡ÔñÓ뱻ѡÔñ

<html>
<head>
<mce:script type = "text/javascript"><!--

function changetext()
{
var x = document.getElementById("list");
for (var i = 0;i < x.length;i++ )
{
if (x.options[i].selected)
{
document.getElemen ......

javascript: The Browser Object Model(BOM)

window
window¶ÔÏóÊÇä¯ÀÀÆ÷»òÕß¿ò¼Ü×ÔÉí.top×ÜÊÇä¯ÀÀÆ÷,parentÊǸ¸¿ò¼Ü,self±íʾ×Ô¼º.
windowͨ³£¿ÉÒÔÊ¡ÂÔ.
´°¿Ú²Ù×÷: moveBy(dx, dy), moveTo(x, y),
resizeBy(dw, dh), resizeTo(w, h).
µ¼º½: window.open(url, frame
name, attribute). attribute¿ÉÒÔÊÇleft, top, height, width, resizable,
scrollable, too ......

javascriptÖеÄevalº¯ÊýµÄÓ÷¨(תÌù)

±¾ÎĵÄÁ½¸öÄ¿µÄ£º
£¨1£©½éÉÜjavascriptÖеÄevalº¯ÊýµÄÓ÷¨
£¨2£©ÈçºÎÔÚº¯ÊýÄÚÖ´ÐÐÈ«¾Ö´úÂë
►ÏÈÀ´ËµevalµÄÓ÷¨£¬ÄÚÈݱȽϼòµ¥£¬ÊìϤµÄ¿ÉÒÔÌø¹ý¡£
evalº¯Êý½ÓÊÕÒ»¸ö²ÎÊýs£¬Èç¹ûs²»ÊÇ×Ö·û´®£¬ÔòÖ±½Ó·µ»Øs¡£·ñÔòÖ´ÐÐsÓï¾ä¡£Èç¹ûsÓï¾äÖ´Ðнá¹ûÊÇÒ»¸öÖµ£¬Ôò·µ»Ø´ËÖµ£¬·ñÔò·µ»Øundefined¡£
ÐèÒªÌرð×¢ÒâµÄÊǶÔÏóÉùÃ÷Óï· ......

À뿪»­ÃæʱµÄJavaScriptÈ·ÈÏÌáʾ

window.onbeforeunload = function (evt) {
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;

onbeforeunload ʼþ²Î¿¼µØÖ·
http://msdn.microsoft.com/en-us/ ......

·ÅÒ»¸öjavascriptÓÒ¼ü²Ëµ¥µÄ´úÂë

×¢²áºÜ³¤Ê±¼äºÅÁË£¬¸Õ¿ªÍ¨²©¿Í£¬ÄóöÒ»¸ö×Ô¼ºÐ´µÄjavascriptÓÒ¼ü²Ëµ¥£¬¼æÈÝIE£¬firefoxä¯ÀÀÆ÷
ÕâÊÇcss´úÂë
 body{
font-size:12px;
}
.contextMenu{
filter:alpha(opacity=80);
opacity:0.8;
border:1px #0033FF solid;
background-color:#0099CC;
cursor:pointer;
width:120px;
position:absolute;
top: ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ