Here's how we use jQuery functions in a separate file:
// globalFunctions.js
// this should be included FIRST
// place this in the script where you want to use these functions:
// <script src="/scripts/globalFunctions.js"></script>
$(function () {
function getBozo() {
return "bozo";
}
function getUrlParameterByName(name) {
// url = current url
var url = window.location.href;
var value = getParameterByName(url, name);
return value;
}
function getParameterByName(url, name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(url);
if (results == null) {
return "";
}
else {
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
}
// all functions must be listed
window.getValue = getBozo;
window.getUrlParameterByName = getUrlParameterByName;
window.getParameterByName = getParameterByName;
})