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);
×¢Ò⣺¿ÉÒÔͨ¹ý°ÑÒ»¸öÖµ¸³
Ïà¹ØÎĵµ£º
¼ò½é
¡¡¡¡1st JavaScript Editor ÊÇÒ»¿îÇ¿´óµÄJavaScript¿ª·¢¡¢Ð£ÑéºÍµ÷ÊÔ¹¤¾ß£¬Ëü¼òµ¥Ò×Ó㬲»ÂÛÄãÊdzõѧÕß»òÕßÊÇרҵµÄ¿ª·¢ÈËÊ¿£¬¶¼¿ÉÒÔÇáËÉÉÏÊÖ£¡Í¬Ê±ËüÓÖÊÇÍêÃÀµÄAjax (Asynchronous JavaScript and XML),CSS, HTML, DOM DHTML¿ª·¢¹¤¾ß£¡
¡¡¡¡Beside rich possibilities of editing scripts (JavaScript, ......
ʹÓÃtry{...}catch(){} ·½Ê½£¬Àý×ÓÈçÏ£º
function showAlarm(strObject){
try{
svgElement = document.getElementById(strObject);
svgElement.setAttribute("visibility","visible");
setTimeout("hideAlarm()",3000);//3Ãëºó½áÊø±¨¾¯
}catch(ex){
alert("º¯ÊýshowAlarm()·¢ÉúÒì³££º"+ex.descrip ......
±¾ÎĵÄÁ½¸öÄ¿µÄ£º
£¨1£©½éÉÜjavascriptÖеÄevalº¯ÊýµÄÓ÷¨
£¨2£©ÈçºÎÔÚº¯ÊýÄÚÖ´ÐÐÈ«¾Ö´úÂë
►ÏÈÀ´ËµevalµÄÓ÷¨£¬ÄÚÈݱȽϼòµ¥£¬ÊìϤµÄ¿ÉÒÔÌø¹ý¡£
evalº¯Êý½ÓÊÕÒ»¸ö²ÎÊýs£¬Èç¹ûs²»ÊÇ×Ö·û´®£¬ÔòÖ±½Ó·µ»Øs¡£·ñÔòÖ´ÐÐsÓï¾ä¡£Èç¹ûsÓï¾äÖ´Ðнá¹ûÊÇÒ»¸öÖµ£¬Ôò·µ»Ø´ËÖµ£¬·ñÔò·µ»Øundefined¡£
ÐèÒªÌرð×¢ÒâµÄÊǶÔÏóÉùÃ÷Óï· ......
var sDate = new Date(Date.UTC(arys[0], arys[1] - 1, arys[2]));
var eDate = new Date(Date.UTC(arys1[0], arys1[1] - 1, arys1[2]));
......
ÔÚjavascript´úÂëÖÐÓÃencodeURIComponent()º¯Êý´¦ÀíÖÐÎÄ×Ö·û´®£¬
JS´úÂ룺
<mce:script type=”text/javascript”><!--
string = encodeURIComponent(string);
location.href = index.php?keyword=’+string;
// --></mce:script>
PHP´úÂë:
<?php
$keyword = (isset($_GET ......