window.location doesn't work after an AJAX request in Internet Explorer

泄露秘密 提交于 2019-11-30 20:39:37

Answer!

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.

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

I have the same problem. One possible solution is changing ajax request from asynchronous to synchronous. If you do that then 'Automatic prompting isn't needed at all.

Try calling setTimeout to perform the navigation a tiny bit later.

You should add a full URL (including http://) for your window.location :-)

I've had the same exact issue a while ago, that was related to the fact that my FQDN had an underscore in it. It is illegal to have an underscore in a FQDN, but only Internet Explorer actually blocks it, while other browsers make it work normally. If you have an underscore, Internet Explorer won't register cookies either...

If that's not your problem, I would suggest to try an e.preventDefault() before the window.location to see what happens.

Try to remove the first slash:

window.location = "deploy/Company.Domain.Product.application?" + tranId;

Maybe IE thinks You are trying to get "deploy" from the root. Anyway I think it's a good practice to use a full url's = No misunderstanding

I agree with Mih, because you can't say to your users to change their browser options. If you use asynchronous request, it might be ok in internet explorer.

You can change your $.post to $.ajax like this:

$.ajax({
  type: 'POST',
  url: url,
  ...
  async:false
});

More info about ajax here: http://api.jquery.com/jQuery.ajax/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!