mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-25 08:34:43 +00:00
Added a script tag inserter to be able to pick jQuery with a url param
This commit is contained in:
parent
ca50119068
commit
9ffedb700b
1 changed files with 24 additions and 0 deletions
24
js/jquery.tag.inserter.js
Normal file
24
js/jquery.tag.inserter.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
(function() {
|
||||
// Insert a script tag pointing at the desired version of jQuery
|
||||
|
||||
// Get the version from the url
|
||||
var jqueryRE = /[\\?&]jquery=([^&#]*)/,
|
||||
results = jqueryRE.exec( location.search ),
|
||||
version = "",
|
||||
jq,
|
||||
myScriptTag = document.getElementsByTagName( "script" )[document.getElementsByTagName( "script" ).length - 1],
|
||||
baseUrl = myScriptTag.src.replace( /(.*)\/.*$/, "$1/" ),
|
||||
url = baseUrl + "jquery-1.7.1.js";
|
||||
|
||||
if( results ) {
|
||||
version = decodeURIComponent(results[results.length - 1].replace(/\+/g, " "));
|
||||
}
|
||||
|
||||
switch( version ) {
|
||||
case "1.6.4":
|
||||
url = baseUrl + "jquery-1.6.4.js";
|
||||
break;
|
||||
}
|
||||
|
||||
document.write( "<script src='"+url+"'></script>" );
|
||||
}());
|
||||
Loading…
Reference in a new issue