【发布时间】:2015-06-19 22:47:35
【问题描述】:
我有以下代码
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”的链接假定其基本路径是提供服务的路径。
-
site.com/test1/test2/test3/test4.php是这样吗,它不会在 test3 目录中寻找index.php吗? -
链接到“/index.php”的链接
-
删除action属性即可。
-
只需
action="/"即可。form没有action无效
标签: javascript jquery base-url