'Internet Explorer not loading js file
I work in a company that has departments in several countries. At our local department we can put our own stuff on the website, but there are quite a few limitations. I've created an order form in html and jquery, everything in one file. It works completely fine when I run this file from C:\ in Internet Explorer, Opera or Firefox.
Enter the limitations imposed on our local websites: I can't enter more than 20 000 characters into an html page. I tested an early version of the form on our local website and it worked, it contained both html and jquery, but it was far below 20 000 characters. The HTML part alone is now 15 000 characters, and the jquery 75 000. Thus it makes sense to put the HTML and the javascript in separate files.
Enter yet another limitation: I cannot upload .js files to our local server. I think I can convince the guys at the main office to let me do this, but it will take some time to convince them. In the meantime I want to find some workaround to publish a functional form, so that our customers can start trying out the order form, and it will be easier to convince the main office when they can see a working demonstration.
https://gist.github.com/ is a place where anyone can enter some javascript and make an accessible javascript. I tried this out with Opera first, and it worked, but for some reason it wouldn't work in Internet Explorer. I've tried lots of different things, until I finally created a completely basic HTML page like this (insert a head to make it work in a browser):
<HTML>
<body>
<style type="text/css">
</style>
<SCRIPT src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></SCRIPT>
<FORM enctype="application/x-www-for m-urlencoded" NAME="orderForm" id="orderForm" ACTION="" METHOD="get">
<input type="button" id="TestButton" onclick="TestFunction()" value="some value">
<SCRIPT src="https://raw.github.com/gist/2643863/30916820b71be3f9b89ad41ef060a2dd784b620e/VerySimpleTest.js" type="text/javascript"></SCRIPT>
<!--SCRIPT src="simpleSCRIPTtest.js"></SCRIPT-->
</form>
</body>
</HTML>
I've alternated between accessing the .js file locally and from the Gist page, thus the commented SCRIPT line. The script is this:
function TestFunction() {
alert("This works!");
}
In Opera it works fine both locally and from Gist. It works fine in IE when loading the script locally, but when I try this with the Gist page as script source and press the button I get the error message "The value of the property 'TestFunction' is null or undefined, not a Function object".
If it were up to me, I would tell all our cusomters to use Opera or Chrome, but I'm afraid that's not an option. Does anyone have any idea why this doesn't work in IE? And if so, any idea of how to create an external .js file that my HTML page can access that works in IE, Opera, Chrome and Firefox?
Solution 1:[1]
We cannot see the document type so if this is not HTML5 you will need to include the type="text/javascript" attribute in your script tags for the simpleSCRIPTtest.js.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jay Blanchard |
