m晴朗 2021-10-29 10:41 采纳率: 100%
浏览 41
已结题

IWebBrowser2使用Navigate2打开的一个网页,网页里的js代码无效

IWebBrowser2使用Navigate2打开的一个网页,网页里的js代码无效,使用IE和Chrome完全正常,尝试把js代码放到外部也不行,有没有遇到过类似情况 的,求大神们帮帮忙!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- saved from url=(0022)http://internet.e-mail -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
<SCRIPT language=javascript>
<!--
    window.onerror = function() { return true; }
// -->
</SCRIPT>
<title>language</title>
<style type="text/css">
    * { margin:0; padding:0;}
    body { line-height:22px; font-size:13px; color:#fff; background:#000; overflow:hidden;}
    .select_box{color:#444;position:absolute;width:210px;height:28px;font-size:12px;background-image:url(SPANISH.png);}
    .selet_open{display:inline-block;border-left:solid 1px #E5E5E5;position:absolute;right:0;top:0;width:30px;height:28px;background-image:url(choiceBtn.png);}
    .option{width:180px;border:solid 1px #EDE7D6;position:absolute;top:28px;left:-1px;z-index:2;overflow:hidden;display:none;}
    .option a{display:block;height:28px;line-height:28px;text-align:left;width:100%;}
        #ESP{background:url(SPANISH.png);}
        #FOR{background:url(PORTUGUESE.png);}
    .option a:hover{background:#FDE0E5;}
</style>
<script src="jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $(".select_box").click(function(event) {
            event.stopPropagation();
            $(this).find(".option").toggle();
            $(this).parent().siblings().find(".option").hide();
        });
        $(document).click(function(event) {
            var eo = $(event.target);
            if ($(".select_box").is(":visible") && eo.attr("class") != "option" && !eo.parent(".option").length)
                $('.option').hide();
        });

        $(".option a").click(function() {
            var value = $(this).attr("id");

            switch ($(this).attr("id")) {
                case "ESP":
                    document.getElementById("select_box").style.backgroundImage = "url(SPANISH.png)";
                    break;
                case "FOR":
                    document.getElementById("select_box").style.backgroundImage = "url(PORTUGUESE.png)";
                    break;
            }
            document.getElementById("select_value").value = value;
            alert(document.getElementById("select_value").value);
        });
    })
</script>
</head>
               
<body scroll="no" background-color="transparent" oncontextmenu=self.event.returnValue=false>
<div class="select_box" id="select_box">
    <a class="selet_open"></a>
    <div class="option">
        <a id="ESP"></a>
        <a id="FOR"></a>
    </div>
</div>
<input type="hidden" id="select_value" />
</body>
</html>

  • 写回答

1条回答 默认 最新

  • CSDN专家-showbo 2021-10-29 10:56
    关注

    题主用的jquery版本是多少的?2+的话不支持IE8-浏览器,网页加一句
    alert(navigator.userAgent)看看输出的IE内核版本是多少的,如C# winform的webbrowser内核是ie7的。
    换个低版本的jquery试试,如1.7.1的jquery,实在不行试试原生js,应该是兼容性有问题

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 11月6日
  • 已采纳回答 10月29日
  • 创建了问题 10月29日

悬赏问题

  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上