How to make java script like that loaded only in homepage and no loaded in other categories , post pages as they'have no slider .. so i no need it !
<script src='http://slideshow.googlecode.com/files/jquery-ui.min.js' type='text/javascript'/>
How to make java script like that loaded only in homepage and no loaded in other categories , post pages as they'have no slider .. so i no need it !
<script src='http://slideshow.googlecode.com/files/jquery-ui.min.js' type='text/javascript'/>
If you don't want the script to load on a page, then don't include it. If you're using a CMS for your site, then post the CMS that you're using so we can help you.
If all that fails, you can set up something like an ID on your body tag. Then you can test the ID of the body, if it passes, execute the code, if it fails, then don't execute it.
--EDIT--
An example would be something like this..
<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>
Try something like that. For a greater explanation for using dynamic JavaScript elements, check out this page: http://unixpapa.com/js/dyna.html
<body id="home"> That's all you have to do. I'll edit my answer to give an example function. But I'm a bit wary to do so. I'd rather have you understand what you're doing, and work out the solution on your own, than have me write you a solution, and you not get why it works.I believe you do something wrong, if you don't need script, just don't load it as Tim answered.
Anyway possible workaround, you can create script yousrcipt.js, include it in every page. In this script you can write something similar to this
if (window.location == 'whateverhomepage') {
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= 'http://slideshow.googlecode.com/files/jquery-ui.min.js';
head.appendChild(script);
}
If you want to controll this behaviour on the client side I would try this approach:
<script>location.pathname == '/' && document.write('<script src="http://slideshow.googlecode.com/files/jquery-ui.min.js">\x3C/script>')</script>
But of course better to let you CMS/server code handle it for you. But based on the information you provided I can only give you client-side solution.