Another way to load js file into js code
I opened a javaScript file in javaScript time ....
document.write("<script src='newnote.js' type='text/javascript'></script>");
Is there any other way to load js into js code.?
(this file is designed to load a pop-up menu of js code, which is loaded after a delay using js clock code ... so I want to use it to load)
Is it possible that the script you are adding to the page (in this case newnote.js) is causing the error you encountered?
Instead of the line you used, starting with document.write, use instead:
var newnote = document.createElement('script');
newnote.src = "newnote.js";
newnote.type = "text/javascript";
document.documentElement.firstChild.appendChild( newnote );
If you still get your quote, then the code inside is newnote.jsmessy.
, , , , , :
document.documentElement.firstChild.removeChild( newnote );
:
newnote.js ( , ), 404 . javascript, . URL-: http://yoursite.com/js/newnote.js : /js/newnote.js
you do not open the javascript file, in fact you cannot open any file from the local file system, so there is no question of closing. You insert a script tag, replacing the entire contents of the document. This will retrieve newnote.js using the current url with newnote.js replacing anything after the last slash.
To enable the script, you can try the following:
var s = document.createElement('script');
s.src = 'newnote.js';
s.type = 'text/javascript';
var head = document.getElementsByTagName('head')[0]
head.appendChild(s);
or so:
document.write("<script type='text/javascript' src='newnote.js'><\/sc" + "ript>");