我正在动态创建 VML 元素。请参阅下面的代码。
<html>
<head>
<!-- VML requires VML namespace and behavior. -->
<script src="http://code.jquery.com/jquery-latest.min.js"
type="text/javascript"></script>
<script type="text/javascript">
//Flag to stop rectangle from spinning.
var spin;
$(document).ready(function () {
document.namespaces.add('v', 'urn:schemas-microsoft-com:vml', "#default#VML");
// Create element in memory.
var r = document.createElement("v:rect");
// Define width, height, color, and unique ID.
$(r).css("width", "100");
$(r).css("height", "100");
$(r).attr("fillcolor", "blue");
$(r).attr("strokecolor", "red");
$(r).attr("strokeweight", "5");
$(r).css('left', '100');
$(r).css('top', '100');
$(r).css('position', 'absolute');
$(r).css('opacity', '0.2');
r.id = "myRect";
// Attach rectangle to the document at the the specified Div.
anchorDiv.appendChild(r);
});
</script>
</head>
<body>
<div id="anchorDiv"></div>
</body>
</html>
它以浏览器模式 -> IE 7 和文档模式 -> IE 5显示输出 。请参考下图。
但是在更改文档模式后-> IE 7没有显示任何内容。(即空白屏幕)。然后 我在 IE 浏览器的开发者工具中点击了两次编辑按钮。请参考下图
它显示矩形。我不知道这是什么原因?有时即使在 IE 5 文档模式本身矩形不显示然后我按照相同的程序(在 IE 浏览器的开发人员工具中单击编辑按钮两次),它会显示矩形。有人可以解释一下这出了什么问题吗?
谢谢,
湿婆