I have to load an HTML file in a existing div when the window's width is smaller than 600px.
The code is:
<head>
<script>
$(document).ready(function(){
if($(window).width() < 600) {
$("#testing_div").load("C:/Users/elena/Desktop/Demo/prova.html");
}
});
</script>
</head>
<body>
<div id="testing_div"> </div>
</body>
I have tested this code on my website and it works, but maybe I am doing something wrong to make it work locally.
Is there a reason why the load
function doesn't work locally but only on a web server?
The reason is security. Running web pages through file://
protocol have disabled a lot of features because security issues. You can make a webserver in javascript through Node.js and you can have a webserver in the local without installing apache or something similar.
Node.js webpage:
https://nodejs.org/en/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With