javascript - 有没有办法添加/更改或删除?(问号)在网址中?
问题描述
我正在尝试在我的 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
?
解决方案
以下是如何将其更改为其他内容:
将更改<action="example.com">
为<action="example.com/example">
,这会将 URL 更改example.com/?example=whatever
为example.com/example?example=whatever
。
推荐阅读
- react-native - 当我开始在其他视图组件中输入数据时,如何防止页面上所有其他组件视图中的数据被清除(重新渲染)?
- python - 如何从 python 读取/抓取 firefox 任务管理器(关于:性能)?
- javascript - jQuery将数据属性添加到代码元素中的元素
- python - 使用 sklearn.neighbors.ball_tree.BinaryTree.query_radius 时出现 MemoryError
- angular - NullInjectorError: R3InjectorError(AppModule)[Router -> Router -> Router]: NullInjectorError: No provider for Router
- kubernetes - 使用 helm 部署应用程序后,面对错误 pod 具有未绑定的立即 PersistentVolumeClaims 附加 pvc
- java - 保存包时出错:/xl/sharedStrings.xml 部分无法使用编组器保存在流中
- ios - 线程 1:“-[Xylophone.ViewController buttonClicked:]:无法识别的选择器发送到实例 0x7ff83a6074e0”
- javascript - 如何通过编译错误停止推送?
- html - 自动填充网格容器,其中一项全宽不留空隙