Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery IE无法加载到div中_Javascript_Jquery_Html_Css_Internet Explorer - Fatal编程技术网

Javascript jquery IE无法加载到div中

Javascript jquery IE无法加载到div中,javascript,jquery,html,css,internet-explorer,Javascript,Jquery,Html,Css,Internet Explorer,我的index.html页面有一个,我需要从位于:content文件夹中的外部*.html文件加载数据。例如,我在content文件夹中创建了两个文件: content/aboutus.html content/contactus.html 要加载数据,我使用hashchange触发器上的jquery <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Test<

我的index.html页面有一个
,我需要从位于:content文件夹中的外部*.html文件加载数据。例如,我在content文件夹中创建了两个文件:

content/aboutus.html
content/contactus.html
要加载数据,我使用hashchange触发器上的jquery

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript" src="scripts/loader.js"></script>
</head>
<body>
        <div class="nav">
            <ul class="navigationList">
                <a href="#aboutus"><li>about us</li></a>
                <a href="#contactus"><li>contact us</li></a>
            </ul>
        </div>
<div id="contentarea"></div>
</body>
</html>
我在Firefox和Safari中成功地测试了它,直到我使用了Internet Explorer。IE完全忽略了
$('#contentarea').load()

我在这方面已经有一段时间了,但是如果没有外部的帮助,我将永远被困

为了纠正这种情况,我编写了检测IE的代码

var href = '';
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
var edge = ua.indexOf('Edge/');
var trident = ua.indexOf('Trident/');

 $(window).on('hashchange', function(){
    href = window.location.hash.substr(1) +".html";

    if (msie > 0  || edge >0 || trident > 0){
         //perform the load in IE working code should go in here
         alert( "Load was performed." );
    }
    else{
        $('#contentarea').load('content/'+href +" #contentarea > *");
    }
 });
我浏览了论坛上的帖子,但不知道如何解决这个问题。
有人能帮我把数据加载到InternetExplorer的div中吗?相同的代码是否适用于所有IE版本?

IE的哪个版本,jQuery的哪个版本?jQuery 2.x不支持旧版本的IE。您收到警报了吗?Javascript控制台中是否有错误?我正在使用IE11。jquery是3.1.0。在执行过程中,我没有在控制台中看到任何错误。警报正在工作,我每次单击按钮都会收到警报。
var href = '';
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
var edge = ua.indexOf('Edge/');
var trident = ua.indexOf('Trident/');

 $(window).on('hashchange', function(){
    href = window.location.hash.substr(1) +".html";

    if (msie > 0  || edge >0 || trident > 0){
         //perform the load in IE working code should go in here
         alert( "Load was performed." );
    }
    else{
        $('#contentarea').load('content/'+href +" #contentarea > *");
    }
 });