javascript语言与html交互的几种方式

来源:互联网 发布:mysql重启命令 编辑:程序博客网 时间:2024/04/27 10:24

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
javascript语言与html交互时,1)onouseover是javascript function 等同于 document.getElementById("table1").onmouseover=function(){this.width=tWidth}, 只是将javascript与html简单化,用一个事件标签(像属性的方式)
2>将整个对象document.write()输出
3>特例, href="alert(11)", 地址栏技持javascript
<table height="200" border="1" id="table1" width="javascript: alert(11)" onmouseover="alert(1)">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<script>
var tWidth="300";
document.write('<table width='+tWidth+' height="200" border="1"><tr>    <td>&nbsp;</td>    <td>&nbsp;</td>  </tr>  <tr>    <td>&nbsp;</td>    <td>&nbsp;</td>  </tr></table>')
</script>
<a href="javascript: alert(123); open(); void(0)">因为地址栏支持javascript, 所以可以在href, window.location.href上可以直接用javascript</a>

<script>
//window.location.href=alert(222);void(0); alert(0);

//window.location.href='';
//window.location.href=alert(11); //说明本页执行完后才能

document.getElementById("table1").width="200";
document.getElementById("table1").style.width="300";

document.getElementById("table1").onmouseover=function(){alert(2)}

document.getElementById("table1").onmouseover() //本身就是一个玩参数,无反回value的委托

document.getElementById("table1").mouseover() //本身就是一个玩参数,无反回value的委托,也不能返回,

</script>


<input type="button" value="test" id="input1">
<script>
document.getElementById("input1").onclick= function(){alert(4)}
document.getElementById("input1").onclick();
document.getElementById("input1").click(); //此可以,特例,
委托function为click, mouseover, raise function为onmoseover, onclick,
说明mouseover不为public, 为private or protect,而click为public,

javascript现有java版及c++版

</script>
 </BODY>
</HTML>

原创粉丝点击