| 5: document.write(thisTimeString “ on “ thisDateString); 6: </script>
32 读取URL参数
1: <script language=”JavaScript”> 2: var urlParts = document.URL.split(“?”); 3: var parameterParts = urlParts[1].split(“&”); 4: for (i = 0; i < parameterParts.length; i ) { 5: var pairParts = parameterParts[i].split(“=”); 6: var pairName = pairParts[0]; 7: var pairValue = pairParts[1]; 8: document.write(pairName “ :“ pairValue ); 9: } 10: </script>
你还以为HTML是无状态的么?
33 打开一个新的document对象
1: <script language=”JavaScript”> 2: function newDocument() { 3: document.open(); 4: document.write(“<p>This is a New Document.</p>”); 5: document.close(); 6: } 7: </script>
34 页面跳转
1: <script language=”JavaScript”> 2: window.location = “http://www.webjx.com/”; 3: </script>
35 添加网页加载进度窗口
1: <html> 2: <head> 3: <script language='javaScript'> 4: var placeHolder = window.open('holder.html','placeholder','width=200,height=200'); 5: </script> 6: <title>The Main Page</title> 7: </head> 8: <body onLoad='placeHolder.close()'> 9: <p>This is the main page</p> 10: </body> 11: </html>
JavaScript就这么回事3:图像
36 读取图像属性
1: <img src="/”image1.jpg"” name=”myImage”> 2: <a href=”# ” onClick=”window.alert(document.myImage.width)”>Width</a> 3:
37 动态加载图像
1: <script language=”JavaScript”> 2: myImage = new Image; 3: myImage.src = “Tellers1.jpg”; 4: </script>
38 简单的图像替换
1: <script language=”JavaScript”> 2: rollImage = new Image; 3: rollImage.src = “rollImage1.jpg”; 4: defaultImage = new Image; 5: defaultImage.src = “image1.jpg”; 6: </script> 7: <a href="/”myUrl"” onMouseOver=”document.myImage.src = rollImage.src;” 8: onMouseOut=”document.myImage.src = defaultImage.src;”> 9: <img src="/”image1.jpg"” name=”myImage” width=100 height=100 border=0>
39 随机显示图像
1: <script language=”JavaScript”> 2: var imageList = new Array; 3: imageList[0] = “image1.jpg”; 4: imageList[1] = “image2.jpg”; 5: imageList[2] = “image3.jpg”; 6: imageList[3] = “image4.jpg”; 7: var imageChoice = Math.floor(Math.random() * imageList.length); 8: document.write(‘<img src=”’ imageList[imageChoice] ‘“>’);
|
| 共9页: 上一页 [1] [2] [3] 4 [5] [6] [7] [8] [9] 下一页 |
评论加载中…