Home Developing - Bootstrap Q&A Issues References Notes History Attic
|
Page 4 of 9 |
This is a re-occurring question during JavaScript livetime. We have implemented this perhaps at several locations. One of them is:
// ... // ...
| . |
In his blog article
Javascript: Path to the current script 2011,
Ben Carpenter explains
a technique to deduce the script path from the script tag in the HTML code
.
// Algorithm to read the script path from the html script tag
// by Ben Carpenter # 20110123.1154
var scriptPath = function ()
{
var scripts = document.getElementsByTagName('SCRIPT');
var path = '';
if(scripts && scripts.length>0) {
for(var i in scripts) {
if(scripts[i].src && scripts[i].src.match(/script\.js$/)) {
path = scripts[i].src.replace(/(.*)script\.js$/, '$1');
}
}
}
return path;
};
|
jsi-boostrap.js |
| . | This page adds to the discussion: http://stackoverflow.com/questions/2161159/get-script-path | (jsi-boostrap.js) |
| . | This page adds more to the discussion: https://github.com/madrobby/scriptaculous/blob/master/src/scriptaculous.js | (jsi-boostrap.js) |
.
[Next question]
[Next answer]
//
| . | . |
. . .