How to add my own js script?
Posted: 07 Jan 2015, 14:38
When I try to add my own javascript in footer section (can't find better place in admin panel), the script seems to be fired ONLY when the page is loaded. After I navigate to another page, the script won't fire again.
I couldn't find any javascript method/listener to check if pathname has been changed (it's "workaround" but I could fire my script then).
Also, I would like to be able to use jQuery. As for now I access jQuery using the code below, but it's not really appropriate way.
I could update imageve files but it's quite uncomfortable because of updates.
Is there a way I could be abble to use jQuery without "workarounds" and add my script which will fire on each page?
I couldn't find any javascript method/listener to check if pathname has been changed (it's "workaround" but I could fire my script then).
Also, I would like to be able to use jQuery. As for now I access jQuery using the code below, but it's not really appropriate way.
Code
function if_jQ_is_loaded(myFunc) {
if (window.$){
myFunc();
}else{
setTimeout(function() { if_jQ_is_loaded(myFunc) }, 100);
}
}
if_jQ_is_loaded(function () {
//blah blah blah...
});
Is there a way I could be abble to use jQuery without "workarounds" and add my script which will fire on each page?