I tried to read the code from my external javascript to another but it won't let me to read it.
I have tried to use this in my javascript:
key.js
function loadjscssfile(filename, filetype)
{
var fileref=document.createElement('script');
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", filename);
}
document.onkeydown = function(ev)
{
var key;
ev = ev || event;
key = ev.keyCode;
var image1 = document.getElementById("image1").getElementsByTagName("img")[0];
if(key == 13)
{
if (img1.indexOf('image1_yellow.jpg') != -1)
{
if (img5.indexOf('picture1_yellow.jpg') != -1)
{
loadjscssfile("test1.js", "js");
}
}
}
test1.js
var teststring="hello! you are reading another javascript file";
alert("teststring);
I can't read the test1.js from the key.js.
any idea?