我有這個下面的代碼的Javascript基址路線
jQuery('#main-menu > ul > li.search')
.append('<ul class="search-box sub-menu"><li><form action="http://####.####.org.uk" id="searchform" method="get"><input type="text" name="s" id="s" placeholder="Search"></form></li></ul>');
這是特別這一點我很感興趣
<form action="http://####.####.org.uk" id="searchform" method="get">
其中####.####.org.uk
是我工作的網站的站點索引,然而,我不需要硬編碼,只需參考基本路徑,例如site.com
,就可以從站點的任何位置調用此代碼,因此可以從site.com/fdsifudfa.php
,site.com/test/test/123/lol.php
調用該代碼。我需要此表單操作才能轉至site.com
。
我不想在這裏有一個固定的網站路徑,因爲這可能是任何東西(代碼可以移動)/被轉售。
則只是將其刪除。鏈接到「index.php」的鏈接假定它的基本路徑是從其提供服務的路徑。 – Sharky
對於'site.com/test1/test2/test3/test4.php'這是否正確,是否不會在test3目錄中查找'index.php'? –
鏈接到「/index.php」< - 注意「/」假定爲根。所以用「/」它不會查找test3目錄。它會查找根目錄。 – Sharky