0
有很多关于此主题的帖子,但其中大多数都是因为IE没有动态设置属性name
。IE发布到HTA中的iframe会打开一个新窗口
我有一个不同的麻烦:我张贴表格(动态创建)iframe
为target
。它第一次很好。然后,我再次执行此操作,IE会打开一个窗体,并提交表单提交的结果。我很确定它与安全问题有关,因为:如果我创建了一个简单的HTML file
(而不是HTA
),它的效果很好。另外,如果我运行的文件不在本地工作(http://local.host/test.hta),它的效果很好。
任何线索怎么回事或我该如何解决?可悲的是,它的遗留代码,我不能避免使用HTA
或iframes
和表单提交。
这里其简单的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<HTA:APPLICATION
ID="oHTAGeneral_v5"
APPLICATIONNAME="TEST"
ICON='Img/icono.ico'
SCROLL="no"
SINGLEINSTANCE="yes"
SELECTION='yes'
NAVIGABLE='yes'
SHOWINTASKBAR='Yes'
WINDOWSTATE='normal' />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.2.6.min.js"></script>
<script type="text/javascript">
$(function() {
var url = "http://www.some-url.com/",
first = true;
$("#frame").unbind("load");
$("#frame").load(function(){
if (first) {
first = false;
$("#frame")[0].contentWindow.document.cookie = "testCookie=dummyValue";
$("<form></form>")
.attr("target", "frame").attr("method", "POST").attr("action", url)
.css("display", "none")
.appendTo($(document.body))
.append('<input type="hidden" name="dummy" value="dummy" />')
.submit();
return;
}
// Other stuff
});
$("<form></form>")
.attr("target", "frame").attr("method", "POST").attr("action", url)
.css("display", "none")
.appendTo($(document.body))
.append('<input type="hidden" name="dummy" value="dummy" />')
.submit();
});
</script>
</head>
<body>
<iframe id="frame" name="frame" width="200" height="50"></iframe>
</body>
</html>