PHP JS各種知識點

來源:互聯網
上載者:User

標籤:

js.php

<script>function message(){alert("該提示框是通過 onload 事件調用的。")}</script></head><body onload="message()"><p><button onclick="FunctionA()">覆蓋</button></p><div id="a">原內容A</div><div id="b">原內容B</div><p><button onclick="FunctionB()">替換</button></p><p id="c"></p><p><button onclick="FunctionC(‘參數一‘,‘參數二‘)">調用帶參數的函數</button></p><p><button onclick="FunctionC(‘第二次參數一‘,‘第二次參數二‘)">第二次調用帶參數的函數</button></p><form action="0805/test.php" onsubmit="return validate_form(this)" method="post">Email: <input type="text" name="email" size="30"><input type="submit" value="提交"> </form></body></html><script>document.write("產生文本,這些寫在/html之後")//產生文本document.write("<h1>產生普通文本和標籤</h1>")//產生普通文本和標籤function FunctionA(){    document.write("如果在文檔已完成載入後執行 document.write,整個 HTML 頁面將被覆蓋:");}function FunctionB(){    document.getElementById("a").innerHTML="替換後A";    document.getElementById("b").innerHTML="替換後B";}function FunctionC(name,job){    alert("Welcome " + name + ", the " + job);}var ab="附的值";document.getElementById("c").innerHTML=ab;function validate_required(field,alerttxt){with (field)  {  if (value==null||value=="")    {alert(alerttxt);return false}  else {return true}  }}function validate_form(thisform){with (thisform)  {  if (validate_required(email,"Email must be filled out!")==false)    {email.focus();return false}  }}</script>

jquery.php

<script type="text/javascript" src="jquery.js"></script><script type="text/javascript">function getElements(){  var x=document.getElementsByName("myInput");  alert(x.length);}function createNewDoc(){  var newDoc=document.open("text/html","replace");  var txt="<html><body>學習 DOM 非常有趣!</body></html>";  newDoc.write(txt);  newDoc.close();}</script></head><body><input name="myInput" type="text" size="20" /><br /><input name="myInput" type="text" size="20" /><br /><input name="myInput" type="text" size="20" /><br /><input type="button" onClick="getElements()" value="名為 ‘myInput‘ 的元素有多少個?" /><br><br><input type="button" value="開啟並寫入一個新文檔" onClick="createNewDoc()"><br><br><a name="first">第一個錨</a><br /><a name="second">第二個錨</a><br /><a name="third">第三個錨</a><br />文檔中錨的數目:<script type="text/javascript">document.write(document.anchors.length)</script><br><br><a name="first">第一個錨</a><br /><a name="second">第二個錨</a><br /><a name="third">第三個錨</a><br />本文檔中第一個錨的 InnerHTML 是:<script type="text/javascript">document.write(document.anchors[0].innerHTML)</script><br><br><form name="Form1"></form><form name="Form2"></form><form name="Form3"></form><script type="text/javascript">document.write("文檔包含: " + document.forms.length + " 個表單。")</script><br><br><form id="Form1" name="Form1">您的姓名:<input type="text"></form><form id="Form2" name="Form2">您的汽車:<input type="text"></form><script type="text/javascript">document.write("<p>要訪問集合中的項目,你既可以使用項目編號:" + document.forms[0].name + "</p>")document.write("<p>要訪問集合中的項目,也可以使用項目名稱:" + document.getElementById("Form1").name + "</p>")</script>

ajax.php

<script type="text/javascript">function showCustomer(str){var xmlhttp;    if (str=="")  {  document.getElementById("txtHint").innerHTML="";  return;  }if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else  {// code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }xmlhttp.onreadystatechange=function()  {  if (xmlhttp.readyState==4 && xmlhttp.status==200)    {    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;    }  }xmlhttp.open("GET","/ajax/getcustomer.asp?q="+str,true);xmlhttp.send();}</script></head><body><form action="" style="margin-top:15px;"> <label>請選擇一位客戶:<select name="customers" onChange="showCustomer(this.value)" style="font-family:Verdana, Arial, Helvetica, sans-serif;"><option value="APPLE">Apple Computer, Inc.</option><option value="BAIDU ">BAIDU, Inc</option><option value="Canon">Canon USA, Inc.</option><option value="Google">Google, Inc.</option><option value="Nokia">Nokia Corporation</option><option value="SONY">Sony Corporation of America</option></select></label></form><br /><div id="txtHint">客戶資訊將在此處列出 ...</div>

json.php

<h2>在 JavaScript 中建立 JSON 對象</h2><p>Name: <span id="jname"></span><br />Age: <span id="jage"></span><br />Address: <span id="jstreet"></span><br />Phone: <span id="jphone"></span><br /></p><script type="text/javascript">var JSONObject= {"name":"Bill Gates","street":"Fifth Avenue New York 666","age":56,"phone":"555 1234567"};document.getElementById("jname").innerHTML=JSONObject.namedocument.getElementById("jage").innerHTML=JSONObject.agedocument.getElementById("jstreet").innerHTML=JSONObject.streetdocument.getElementById("jphone").innerHTML=JSONObject.phone</script>

PHP JS各種知識點

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.