1
如何使用JavaScript檢查加載的腳本(而不是加載的腳本路徑)?如何檢索剛加載的頁面的文件名?
例子:
加載腳本的index.php
- 如果我使用window.location.pathname,我得到
/folder1/folder2/Index.php
。 - 如果我使用window.location.href,我得到
http://www.website.com/folder1/folder2/Index.php
。 - 如果我使用window.location.hostname,我得到
www.website.com
。
我應該怎樣才能得到Index.php
?
只有工作,如果該文件在URL中有參數以「/」,不是嗎? – Alexis
@Alexis'pathname'不包含querystrings /參數。 – Curt
好的,謝謝:) – Alexis