我想在除了主頁(索引)以外的每個站點上執行jquery操作。
我不能找出如何設置的if語句與window.location的
感謝您的幫助if window.location == index(homepage)
-1
A
回答
0
你可以這樣做:
if(window.location.pathname != "{ do something }") { //run home page jquery. }
但是如果喜歡PHP像
<?php if (!is_home()) { ?> ==== jquery code here ===== <?php } ?>
祝你好運! :)
0
這應該做你正在尋找的路徑名將是一個/如果你在MVC的主頁。我不確定webforms,但假設它不是像/Default.aspx這樣的頁面名稱。
(function selfRunning() {
if (window.location.pathname.length > 1) {
alert(window.location.pathname);
}
})();
相關問題
- 1. htacces if if index or admin
- 2. 使用RewriteEngine重定向/ URL到/ homepage/index/en
- 3. Mediawiki interlanguage homepage
- 4. Django Homepage 400 debug = False
- 5. wordpress homepage not not url
- 6. RewriteCond for homepage not working
- 7. Angular homepage沒有顯示
- 8. Window.Location?
- 9. ng-if導致$ parent。$ index被設置爲$ index
- 10. 如何爲mysql製作DROP INDEX IF EXISTS?
- 11. jquery:delay()+ window.location?
- 12. 在if條件中使用window.location在CSS文件之間切換
- 13. 變遷==來===在IF(window.location的==「X」)導致塊不執行
- 14. 了window.location = window.location的不是在IE7
- 15. Yii + renderPartial + window.location
- 16. 我在哪裏定義http:// localhost:8080 /「homepage」
- 17. window.location不是woking
- 18. phonegap window.location不能用.html#頁面
- 19. Javascript echo window.location
- 20. javascript - window.location或document.location
- 21. aboout window.location和window.open
- 22. window.location和SEO
- 23. 設置JavaScript window.location
- 24. window.location的在IE8
- 25. Mobile safari:frame.src vs window.location
- 26. window.top.location vs window.location
- 27. 隱藏window.location網址
- 28. window.location =''不起作用;
- 29. window.location - javascript - 不工作
- 30. 的onsubmit window.location的工作不
如果我想瞄準www.exmaple.com的索引,「做某事」看起來會是什麼樣子。我testet「www.example.com」和「http://www.example.com/index.php」沒有任何工作。我不能使用php,因爲它在我們的cms中被阻塞。我的代碼看起來像這樣:if($(window).width()> 1404 &&(window.location.pathname!=「http://www.example.com/index.php」)){ \t做點什麼 \t}' – Corrado 2014-11-21 16:57:49
..hm ..how blocked?您使用哪個CMS? :) – 2014-11-21 17:23:52