Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
393 views
in Technique[技术] by (71.8m points)

javascript - Object doesn't support property or method WebBrowser Control

I have developed a mobile app (in asp.net) and I am using a WinForms application with the WebBrowser control to demo it.

I my main page I am using a script to hide the address bar:

<script type="text/javascript">
    window.addEventListener("load", function () {
        // Set a timeout...
        setTimeout(function () {
            // Hide the address bar!
            window.scrollTo(0, 1);
        }, 0);
    });
</script>

This has worked ok an several machines but this morning on a new machine I encountered an popup when the page loads:

enter image description here

The machine in question has IE9 installed and I have the Disable Script Debugging setting Checked.

What is the best way to tackle this issue. Can I add some condition in the JS to not execute when running in IE?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I know that this problem is from 2012 but there is an answer for it.

At the top of the <head> document where script is added you need to write

<meta http-equiv="X-UA-Compatible" content="IE=edge">

WinForms WebBrowser control is using Internet Explorer but you need to force the latest version there. For eg. if you are using jQuery 2+ it requires IE 9+ so you need to use at least version 9 or later.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...