tags:

views:

56

answers:

2

Hello,

I've a problem with $.getScript that dosen't seem to interact with my primary script :

var noFocus = true; 

$(document).keydown(function (e) {

alert(noFocus);
$.getScript("myscript.js");

});

and myscript.js :

noFocus = false;

But on keydown the alert is ever true... ?

A: 

Try clicking on the page first to give focus and then press a key. You might want to change the keydown event to something else for it to be useful.

Kimmo Puputti
A: 

var noFocus = true;

var myFuncX = function(){ alert("myFuncX " +noFocus); }

$(document).keydown(function (e) {

alert("B " + noFocus); $.getScript("myscript.js"); alert("A " +noFocus);

});

myscript.js:

noFocus = false; myFuncX();

andres descalzo