在Internet Explorer中的AJAX请求后,window.location不起作用 [英] window.location doesn't work after an AJAX request in Internet Explorer

查看:253
本文介绍了在Internet Explorer中的AJAX请求后,window.location不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过网页上的链接启动ClickOnce应用程序。链接必须转到服务器才能启动应用程序之前请求事务GUID。代码的工作方式如下:

I am trying to launch a ClickOnce application via a link on a web page. The link has to go to the server to request a transaction GUID before it can launch the application. The code works like this:

function clickHandler() {
    $.post('/gettransactionid.aspx', function(tranId) {
        console.log("BEFORE");
        window.location = "/deploy/Company.Domain.Product.application?" + tranId;
        console.log("AFTER");
    });
    return false;
}

这在Firefox中运行得非常好但在IE中它可以实现导航并且不会打开clickonce应用程序。在IE8开发工具的控制台窗口中显示控制台.log BEFORE和AFTER。任何帮助将不胜感激,因为我花了4个小时试图用各种黑客解决它!

This works perfectly fine in Firefox but in IE it peforms a navigation and doesn't open the clickonce application. The console.log BEFORE and AFTER are shown in the console window in IE8 dev tools. Any help would be appreciated as I've spent 4 hours on this trying to solve it with various hacks!

我试过:


  • 将window.location更改为window.open。这只是启动窗口一秒钟而无法启动应用程序。

  • 一个警报而不是window.location。这没什么。

  • 针对IE7,IE8和IE9。

  • 通过将浏览器安全性添加到队列并处理windows.location来规避浏览器安全性。根窗口上下文。

  • 我检查了gettransactionid.aspx返回事务ID。

  • 在Firefox中执行它 - 它工作正常。

  • changing the window.location to a window.open. This just fires up a window for a second and fails to launch the application.
  • an alert instead of window.location. This does nothing.
  • Against IE7, IE8 and IE9.
  • Circumventing browser security by adding it to a queue and processing the window.location in the root window context.
  • I have checked gettransactionid.aspx returns the transaction id.
  • Doing it in Firefox - it works fine.

在Microsoft的文档中找到答案:

Found the Answer in Microsoft's documentation:

如果您开发了一个使用Active Scripting启动ClickOnce应用程序的自定义网页,您可能会发现该应用程序无法在某些计算机上启动。 Internet Explorer包含一个名为自动提示文件下载的设置,该设置会影响此行为。此选项菜单中的安全选项卡上提供了此设置,该设置会影响此行为。它被称为自动提示文件下载,它列在下载类别下面。对于Intranet网页,该属性默认设置为启用,默认情况下,Internet网页设置为禁用。当此设置设置为禁用时,将阻止以编程方式激活ClickOnce应用程序的任何尝试(例如,通过将其URL分配给document.location属性)。在这种情况下,用户只能通过用户启动的下载启动应用程序,例如,通过单击设置为应用程序URL的超链接。

If you have developed a custom Web page that launches a ClickOnce application using Active Scripting, you may find that the application will not launch on some machines. Internet Explorer contains a setting called Automatic prompting for file downloads, which affects this behavior. This setting is available on the Security Tab in its Options menu that affects this behavior. It is called Automatic prompting for file downloads, and it is listed underneath the Downloads category. The property is set to Enable by default for intranet Web pages, and to Disable by default for Internet Web pages. When this setting is set to Disable, any attempt to activate a ClickOnce application programmatically (for example, by assigning its URL to the document.location property) will be blocked. Under this circumstance, users can launch applications only through a user-initiated download, for example, by clicking a hyperlink set to the application's URL.

2011年9月1日更新:具有讽刺意味的是,由于自动提示下载被删除,现在已经完全破坏了IE9。

Update 1st September 2011: Ironically this has now broken entirely in IE9 thanks to "Automatic prompting for downloads" being removed.

推荐答案

答案!


如果您开发了一个使用Active Scripting启动ClickOnce应用程序的自定义网页,您可能会发现该应用程序不会在某些机器上启动。 Internet Explorer包含一个名为自动提示文件下载的设置,该设置会影响此行为。此选项菜单中的安全选项卡上提供了此设置,该设置会影响此行为。它被称为自动提示文件下载,它列在下载类别下面。对于Intranet网页,该属性默认设置为启用,默认情况下,Internet网页设置为禁用。当此设置设置为禁用时,将阻止以编程方式激活ClickOnce应用程序的任何尝试(例如,通过将其URL分配给document.location属性)。在这种情况下,用户只能通过用户启动的下载启动应用程序,例如,通过单击设置为应用程序URL的超链接。

If you have developed a custom Web page that launches a ClickOnce application using Active Scripting, you may find that the application will not launch on some machines. Internet Explorer contains a setting called Automatic prompting for file downloads, which affects this behavior. This setting is available on the Security Tab in its Options menu that affects this behavior. It is called Automatic prompting for file downloads, and it is listed underneath the Downloads category. The property is set to Enable by default for intranet Web pages, and to Disable by default for Internet Web pages. When this setting is set to Disable, any attempt to activate a ClickOnce application programmatically (for example, by assigning its URL to the document.location property) will be blocked. Under this circumstance, users can launch applications only through a user-initiated download, for example, by clicking a hyperlink set to the application's URL.

因此,请更改IE安全设置以打开文件下载的自动提示。

So change the IE security settings to turn automatic prompting for file downloads on.

这篇关于在Internet Explorer中的AJAX请求后,window.location不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆