X
X
xmoonlight2016-08-07 15:32:40
JavaScript
xmoonlight, 2016-08-07 15:32:40

How to implement in JS an analogue of include HTML code in IE from a LOCAL file (file:///)?

Hello.
I'm trying to dynamically include content from an HTML file into the main page on IE locally .

What I have already tried:
1. $('#mainmenu').load("mainmenu.html");
2.

function getXmlString(xml) {
  if (window.ActiveXObject) { return xml.xml; }
  return new XMLSerializer().serializeToString(xml);
}
$.get( "mainmenu.html", function( data ) {
     $('#mainmenu').html(getXmlString(data));
});

Result (same for both cases):
On the host: works everywhere and in all browsers, including IE.
Local (run from file:/// .....): works everywhere and in all browsers except IE.

How to make IE work like everyone else?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xmoonlight, 2016-08-13
@xmoonlight

Here it is - works:
https://github.com/xmoonlight/includeHTML

A
A person from Kazakhstan, 2016-08-07
@LenovoId

<html>
<head>
    <script
        src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js">
    </script>
</head>

<body>
    <div id="load_div">111</div>

    <input type='file'>
</body>

<script>
    input = document.querySelector('input');
    input.onchange = function() {
        f = window.URL.createObjectURL(this.files[0]);
        auto_refresh = setInterval(function() {
            // $.ajaxSetup ({cache: false});
            $('#load_div').fadeOut('slow').load(f).fadeIn("slow");
        }, 500);
    }
</script>

try this in my case it works everywhere

E
Eugene, 2016-08-08
@AppFA

And what prevents to raise the local server and run from there? For simplicity, you can put some kind of browser-sync and there will be no problems with running it on a local machine, put it - configure it for 10 minutes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question