-
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="webProject.兼容非兼容.WebForm1" %>
-
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
-
-
<html xmlns="" >
-
<head runat="server">
-
<title></title>
-
<script type="text/javascript">
-
function clk() {
-
var VLCObj = document.getElementById('MyOject0');
-
if ( VLCObj != null )
-
{
-
alert(VLCObj.data);
-
VLCObj.data = "";
-
}
-
alert(VLCObj.data);
-
-
var VLCObj1 = document.getElementById('myTest');
-
if (VLCObj1 != null)
-
{
-
alert(VLCObj1.data);
-
VLCObj1.data = "";
-
}
-
alert(VLCObj1.data);
-
}
-
</script>
-
</head>
-
<body>
-
<form id="form1" runat="server">
-
<div>
-
<div id="myTest" onclick="clk()">mytest</div>
-
</div>
-
<object width="301" height="230" title="" id="MyOject0" classid="clsid:52c209fd-75f6-41da-893f-fbda4a1bb1b8" style="background-color: black; display: block;"/>
-
</form>
-
</body>
-
</html>
如上代码
非兼容模式下,object元素是默认有一个data值,且为空,当我们为它赋值后,这个值会变为,当前URL.
兼容模式下,object元素是无默认data值,为undefined,当我们为它赋值后,这个值就为空.
所以在使用自定义属性时,应避免使用data之类可能为保留字的名称。
阅读(4846) | 评论(1) | 转发(0) |