making js local function globally accessible

JavaScript
window.checkCookie=function(){
 // do whatever you want here
};
Source

Also in JavaScript: