jQuery在codeigniter中查找URI

| 我有一个脚本可以在我的codeigniter网站的每个页面上运行。
jQuery(document).ready(function($) {
    Cufon.replace(\'h1\');
    $(\'#term\').hint();

    setTimeout(\'changeImage()\',9000);
});
如果我在基本url上并且URI中没有任何段,我只希望最后一行
setTimeout(\'changeImage()\',9000);
(只希望它在我的首页上运行)。 是否可以用jQuery做某种类型的“ 2”语句并确定URI中是否没有段? 谢谢     
已邀请:
使用window.location
if ( window.location == YOUR_BASE_URL ) {
    setTimeout(\'changeImage()\',9000);
}
    
好了,您可以使用window.location使用简单的javascript做到这一点,您需要担心三件事:路径名,搜索和哈希,代码将类似于:
var win_location = window.location;
if ( win_location.pathname === \"\" || win_location.pathname === \"/\" && win_location.hash === \"\" && win_location.search === \"\")
{
   // I\'M HOME NOW DO SOMETHING
} 
// hash will be for things like #anchor in the url
// search will be for things like ?param1=john&param2=doe
// so if you need those for some kind of dynamic handling on the home page remove the
// matching condition
    

要回复问题请先登录注册