简体   繁体   English

<img onclick=“”> (带有内联函数调用)在IE中不起作用

[英]<img onclick=“”> (with inline function call) doesn't work in IE

I have the following code: 我有以下代码:

<img 
   title="Delete file" 
   onclick="DeleteFormAttachment('05177434-3132-4cd8-8e31-bae26dde194e');" 
   src="../SiteAssets/images/file_delete.png">

When the user clicks the image, the DeleteFormAttachment function is supposed to run. 当用户单击图像时,应该运行DeleteFormAttachment函数。 The first line in that function is a call to window.confirm() , which makes it very obvious when the function runs or doesn't run. 该函数的第一行是window.confirm()的调用,这使该函数在运行或不运行时都非常明显。 If it doesn't run, there's no popup dialog. 如果它没有运行,则没有弹出对话框。

So this code works fine in Chrome, but fails in IE11. 因此,此代码在Chrome中运行正常,但在IE11中失败。 Nothing happens when the user clicks the <img> . 用户单击<img>时没有任何反应。

The weirdest thing is that I managed to make it work as follows: - Open Dev Tools in IE11. 最奇怪的是,我设法使其工作如下:-在IE11中打开开发工具。 - Copy the content of the onclick attribute, and leave it blank. -复制onclick属性的内容,并将其留空。 Press Enter to save the change to DOM. 按Enter键将更改保存到DOM。 - Edit the onclick attribute again and paste the exact same call to DeleteFormAttachment . -再次编辑onclick属性,并将完全相同的调用粘贴到DeleteFormAttachment Press Enter. 按Enter键。 - Now the function runs when the user clicks on the <img> . -现在,该功能在用户单击<img>

That is a very strange behaviour. 这是一个非常奇怪的行为。 Any ideas? 有任何想法吗?

Found that the problem only occurs in IE11 inside an Azure Virtual Machine running Windows Server 2012. 发现该问题仅发生在运行Windows Server 2012的Azure虚拟机中的IE11中。

If I run IE9 in another VM, or if I run IE11 on my own computer, the code works fine. 如果我在另一个VM上运行IE9,或者如果我在自己的计算机上运行IE11,则代码可以正常工作。

I assume the problem is in IE11 security settings on the server, although I don't know which settings exactly. 我认为问题出在服务器上的IE11安全设置中,尽管我不知道确切的设置。

Just Do allow script in your ES11 browser like, 只要在ES11浏览器中允许脚本,例如,

在此处输入图片说明

And then you are able to do this task, see 然后您可以执行此任务,请参阅

在此处输入图片说明

Thank you 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM