2011-11-12 61 views

回答

3
var sPath = window.location.pathname; 
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1); 
if(sPage == "index.php"){ 
    do something 
} 
else if(sPage == "contact.php"){ 
    do something else 
} 
2

你可以看看window.location.pathname,會給你這樣的:

"https://stackoverflow.com/questions/8102940/javascript-check-what-page-has-loaded" 

這個問題頁面。

+0

的確如此...... – naveen

0

您可以檢查document.URL以查明加載了哪個頁面。