js获取object标签对象失败

描述:ie下无法正常获取到对象,报CVR_IDCard未定义,去掉form标签时,可以正常获取到对象
原因:可能是ie环境下object标签对象在form标签中无法获取,改成div标签的话可以正常获取
代码:

 

<html>
	<head>
		<title>表单页面脚本获取object标签对象失败</title>
		<script language="JavaScript">
			function Save_IDCard() {
				var pName = CVR_IDCard.name;//出错语句
				/**改为如下语句**/
				//var pName = document.getElementById("CVR_IDCard").name;
				alert("pName = " + pName);
			}
		</script>
	</head>
	<body style="padding: 0; margin: 0;">
	<form id="save" name="document_content"
		onsubmit="customOnsubmit(); return true;" action="save" method="post">
	<object id="CVR_IDCard" align="center" name="CVR_IDCard" width="119"
		classid="clsid:10946843-7507-44FE-ACE8-2B3483D179B7"
		codebase="CVR100.cab#version=3,0,3,3" height="136" hspace="0"
		vspace="0"></object> <input type="button" value="aaa" name="aaa"
		onclick="Save_IDCard();" /></form>
	</body>
</html>

 

你可能感兴趣的:(Object标签,IE浏览器兼容,js获取对象)