Is it possible that the script that you are adding to the page (in this case newnote.js
) is causing the error you are experiencing?
Instead of the line you used starting with document.write
use this instead:
var newnote = document.createElement('script');
newnote.src = "newnote.js";
newnote.type = "text/javascript";
document.documentElement.firstChild.appendChild( newnote );
If you still get your quotes error, then the code inside of newnote.js
is messed up.
Don't think this was really what you were asking, but if you used the code I listed above you could then remove this file from your page by calling this:
document.documentElement.firstChild.removeChild( newnote );
One more thought:
If your path to newnote.js
is not correct (because it is not in the same directory as the calling page) then the server would return a 404
error page instead of the file. If your browser tried to execute it like javascript, it could throw an error. Try supplying the full URL: http://yoursite.com/js/newnote.js
or a root relative one: /js/newnote.js