如何在JavaScript中使用旧版DOM方法访问文档属性?
要在JavaScript中使用旧版DOM方法访问文档属性,您可以尝试运行以下代码-
示例
<html>
<head>
<title> Document Title </title>
<script>
<!--
function myFunc() {
var ret = document.title;
alert("Document Title : " + ret );
var ret = document.URL;
alert("Document URL : " + ret );
var ret = document.forms[0];
alert("Document First Form : " + ret );
var ret = document.forms[0].elements[1];
alert("Second element : " + ret );
}
//-->
</script>
</head>
<body>
<h1 id="title">This is main title</h1>
<p>Click the following to see the result:</p>
<form name="FirstForm">
<input type = "button" value = "Click Me" onclick = "myFunc();" />
<input type = "button" value = "Cancel">
</form>
<form name="SecondForm">
<input type = "button" value = "Don't ClickMe"/>
</form>
</body>
</html>热门推荐
10 给女儿祝福语简短精辟
11 2026年祝福语大全简短
12 高考毕业祝福语简短励志
13 鼠年新年贺卡祝福语简短
14 怎样给人送祝福语简短
15 舞台上祝福语大全简短
16 对别人新年祝福语简短
17 表妹结婚祝福语简短藏语
18 新娘对伴娘祝福语简短