20170710

xiaoxiao2021-02-28  117

页面加载立即执行js 不属于任何函数的语句页面加载立即执行 document.write加载后使用覆盖整个文档 style="width:100px;height:100px;font-size:20px"  语句 单击onclick    默认值value

双击ondblclick 

警告:

function JG(){ //document.write("<h1>开黑吗</h1>");  //这句调用就回刷新页面 alert("我盖伦贼66666666666666666666了"); }

<hr/> <div align="center"> <input type="button" value="警告" οnclick="JG()" style="width:100px;height:100px;font-size:20px"/> </div>

询问:

<hr/> <div align="center"> <input type="button" value="询问" οnclick="XW()" style="width:100px;height:100px;font-size:20px"/> </div>

function XW(){ prompt("输入开黑队友名称","燧先生"); }

确认:

function QR(){ alert(confirm("是否确认开黑")); }

<hr/> <div align="center"> <input type="button" value="确认" οnclick="QR()" style="width:100px;height:100px;font-size:20px"/> </div>

读取:

<hr/> <div align="center" > <input type="button" value="读取" οnclick="testA()"/> <input type="text" id="email"/> </div>

function testA(){ var email=document.getElementById("email"); alert(email.value); alert(email.id); document.getElementById("email").value="aaaaaa@qq.com"; }

整体代码块:

<html><head>

<script > function JG(){ //document.write("<h1>开黑吗</h1>");  //这句调用就回刷新页面 alert("我盖伦贼66666666666666666666了"); } function XW(){ prompt("输入开黑队友名称","燧先生"); } function QR(){ alert(confirm("是否确认开黑")); } function testA(){ var email=document.getElementById("email"); alert(email.value); alert(email.id); document.getElementById("email").value="aaaaaa@qq.com"; } function testB(){ var tp=document.getElementById("tp1"); alert(tp.id); alert(tp.src); if(tp.src=="http://localhost/20170710/img/aaa.jpg"){ tp.src="img/bbb.jpg"; }else{ tp.src="img/aaa.jpg"; } alert(tp.src); } var i=1; function testBB(){ var tp=document.getElementById("tp3"); if(i%2==1){ tp.src="img/bbb.jpg"; }else{ tp.src="img/aaa.jpg"; } i++; } function testBBB(){ var tp=document.getElementById("tp5"); alert(tp.id); alert(tp.src); if(tp.src=="http://localhost/20170710/img/aaa.jpg"){ tp.src="img/bbb.jpg"; }else{ tp.src="img/aaa.jpg"; } alert(tp.src); } </script>   </head>      <body> <hr/> <div align="center"> <h1>复习js</h1> </div> <hr/> <div align="center"> <input type="button" value="警告" οnclick="JG()" style="width:100px;height:100px;font-size:20px"/> </div> <hr/> <div align="center"> <input type="button" value="询问" οnclick="XW()" style="width:100px;height:100px;font-size:20px"/> </div> <hr/> <div align="center"> <input type="button" value="确认" οnclick="QR()" style="width:100px;height:100px;font-size:20px"/> </div> <hr/> <div align="center"> <input type="button" value="双击确认" οndblclick="QR()" style="width:100px;height:100px;font-size:20px"/> </div> <hr/> <div align="center" > <input type="button" value="读取" οnclick="testA()"/> <input type="text" id="email"/> </div> <hr/> <div align="center" > <input type="button" value="图片" οnclick="testB()"/><br/> <img src="img/aaa.jpg" id="tp1"/><br/> <img src="img/bbb.jpg" id="tp2"/><br/> </div> <hr/> <div align="center" > <input type="button" value="图片" οnclick="testBB()"/><br/> <img src="img/aaa.jpg" id="tp3"/><br/> <img src="img/bbb.jpg" id="tp4"/><br/> </div> <hr/> <div align="center" > <input type="button" value="图片" οnclick="testBBB(this)"/><br/> <img src="img/aaa.jpg" id="tp5"/><br/> <img src="img/bbb.jpg" id="tp6"/><br/> </div> </html>

转载请注明原文地址: https://www.6miu.com/read-50562.html

最新回复(0)