C#WebBrowser组件忽略window.location.href = url [英] C# WebBrowser component ignores window.location.href = url

查看:110
本文介绍了C#WebBrowser组件忽略window.location.href = url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将asp.net mvc应用程序显示在c#webbrowser组件中。除文件下载外,一切正常。
在这个mvc应用程序中有很多副组件,所以没有找到其他方法来处理downloadFileLink但是使用以下JS:

I'm trying to make asp.net mvc application to be shown in c# webbrowser component. Everything works fine except file downloading. In this mvc application there is a lot of side components, so there was found no other way to handle downloadFileLink but to use following JS:

function downloadButtonClick(s, e, buttonID, actionUrl) {
    var downloadUrl = actionUrl + '?FileID=' + s.GetRowKey(e.visibleIndex);
    if (e.buttonID == buttonID) {
        window.location = downloadUrl;
    }
}

这种方法在我尝试下载时工作正常使用任何浏览器通过此链接提交文件,除了webbrowser组件。

它似乎忽略了所有 window.location 操作(我试过 window.location.href = downloadUrl window.location.replace(downloadUrl)

this approach works fine while I'm trying to download file by this link using any browser, except webbrowser component.
It seems to ignore all window.location manipulations(I've tried window.location.href = downloadUrl and window.location.replace(downloadUrl))

任何人都可以说明这种行为的原因吗?

Can anyone give a reason to this behavior?

推荐答案

如果您的网页无法正常运行WebBrowser控件,但在完整的Internet Explorer浏览器中运行良好,请考虑实现功能控制

In case your web page doesn't work properly in WebBrowser control, but does well in the full Internet Explorer browser, consider implementing Feature Control.

这篇关于C#WebBrowser组件忽略window.location.href = url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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