首页 > 解决方案 > 有没有办法添加/更改或删除?(问号)在网址中?

问题描述

我正在尝试在我的 Github 网站上创建一个搜索栏。这是搜索栏的代码:

<!-- HTML for SEARCH BAR -->
<div id="header">
<form id="newsearch" method="get" action="https://itac85.github.io/Basic-Search-Engine">
<input type="text" class="textinput" name="search" size="21" maxlength="120"><input type="submit" value="Search!" class="button">
</form>
<div class="tfclear"></div>
</div>

当我尝试这个时,它会添加 URL /?search=whatever,这会导致链接不起作用。

如果我更改method="get"method="post",GitHub 会给我一个405 Not Allowed错误。

有没有办法(在 html、css 和/或 JavaScript 中)?完全删除,或将其更改为其他内容,例如search?search=whatever

标签: javascripthtmlcss

解决方案


以下是如何将其更改为其他内容:

将更改<action="example.com"><action="example.com/example">,这会将 URL 更改example.com/?example=whateverexample.com/example?example=whatever


推荐阅读