如何使用 W3C DOM 方法访问文档属性?
版本的 Microsoft Internet Explorer 浏览器中新引入的IE4文档对象模型(DOM)。IE5和以后版本包含对大多数基本的W3C DOM 特性的支持。
示例
可以尝试运行下面的代码以使用 W3C DOM 方法访问文档属性 -
<html>
<head>
<title> Document Title </title>
<script type="text/javascript">
<!--
function myFunc() {
var ret = document.getElementsByTagName("title");
alert("Document Title : " + ret[0].text );
var ret = document.getElementById("heading");
alert(ret.innerHTML );
}
//-->
</script>
</head>
<body>
<h1 id="heading">This is main title</h1>
<p>Click the following to see the result:</p>
<form id="form1" name="FirstForm">
<input type = "button" value = "Click Me" onclick = "myFunc();" />
<input type = "button" value = "Cancel">
</form>
<form d="form2" name="SecondForm">
<input type = "button" value = "Don't ClickMe"/>
</form>
</body>
</html>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP