in my widgets html-template I have following a-tag:
<a class="mylink" href="" data-dojo-attach-point="downloadAttach"
dojoattachevent="onclick:_download">
<div class="mylinklayout"></div>
</a>
When clicked a file should be downloaded and the `href-attribute is set programmatically. This works fine in Chrome & Firefox, but not in IE11. The same happens wenn replacing the div-tag with a img-tag. All javascript code in the background will be executed as expected and only the download will not start (also IE11 does not prompt for saving/directly opening the file).
The download will only work when I'm not using div or img but only plain text within the a-tag (making a usual hyperlink):
<a class="mylink" href="" data-dojo-attach-point="downloadAttach"
dojoattachevent="onclick:_download">
download here
</a>
The javascript code remains unchanged and the href-attribute is set in the same way with the same value. Now it works in IE11.
Is there a work around for IE11 to get this working with div oder img?
答案 0 :(得分:0)
我找到了它在旧IE版本中工作的原因,但在IE11中没有。这段代码片段是由IE浏览器制作的:
var scope = this;
setTimeout(function() { scope.close(); }, 500);
似乎在IE中,点击处理程序在下载时不应立即处理,因此在检测到IE时执行此代码:之前的IE检查是使用dojo.isIe
完成的,现在已完成sniff("ie")
。使用此检查不会检测到IE11,必须检查trident
。现在,代码片段也将针对IE11执行,一切正常。