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

<!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").οnmοuseοver=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)" οnmοuseοver="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").οnmοuseοver=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").οnclick= 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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值