0
Je veux essayer une lib ala jquery mais je ne comprends pas pourquoi ma méthode getUrl ne produit rien, n'est-ce pas?javascript fonction anonyme: pourquoi mon script ne fonctionne pas
mylib.js
(function() {
var scripts = document.getElementsByTagName('script');
var index = scripts.length - 1;
var thisScript = scripts[index];
var myLib = {
getUrl: function() {
return thisScript;
}
}
}
if (!window.$$) {window.$$ = myLib}
)();
et à mytest.html
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.js"></script>
<script src="mylib.js" type=text/javascript></script>
</head>
<body>
<DIV id=url>url</DIV>
<script>
var url = $$.getUrl();
jQuery("#url").html(url);
</script>
</body>
</html>
merci je trouve difficile de trouver des erreurs :) – user310291