、それが含まれていません。サイトでCMSを使用している場合は、使用しているCMSを投稿してください。
すべてが失敗した場合は、body
タグにIDのようなものを設定できます。その後、コードが実行された場合はコードを実行し、失敗した場合はコードを実行し、実行しないでください。
--EDIT--
の例では、このようなものになるだろう。..
<body id="home">
<script language="JavaScript">
function init() {
if(document.getElementsByTagName('body')[0].id == 'home') {
// We're grabbing the head and the script
var headElement = document.getElementsByTagName('head')[0],
scriptElement = document.createElement('script');
// We're setting the new script element to use the URL of the script we want
scriptElement.type= 'text/javascript';
scriptElement.src= 'http://slideshow.googlecode.com/files/jquery-ui.min.js';
// We're adding this newly created element to the head
headElement.appendChild(scriptElement);
}
}
init();
</script>
...
</body>
そのような何かを試してみてください。
<script>location.pathname == '/' && document.write('<script src="http://slideshow.googlecode.com/files/jquery-ui.min.js">\x3C/script>')</script>
しかし、もちろん、より良いようにする:あなたは、私はこのアプローチをしようと、クライアント側でこの動作をcontrollしたい場合http://unixpapa.com/js/dyna.html
出典
2012-01-31 12:14:53
Tim
あなたは他の人と区別されるように具体的にする必要があります。サーバーサイドのPHP、.Net ...を使用していますか? –
ええ、これはJavaScriptの問題ではありません。これはサーバー側の問題です。あなたがサーバーサイドを変更することにある程度制限されているなら、何もできません。もしそうでなければ、PHP/.NET/Python/Perl/Ruby/whatever/batman/watmanスクリプトを書いてこれを処理しなければなりません。おそらく、あなたはいくつかの素晴らしいテンプレートシステムを使用します。 – freakish