繁体   English   中英

域后重定向到网址

[英]Redirect to Url after domain

我想通过单击按钮获得重定向,我使用:

<inputtype="submit" onclick="location.href='first';" value="goSomewhere1"/>
<inputtype="submit" onclick="location.href='second';" value="goSomewhere2"/>

如果在页面http://ADDRESS上单击,但在urlhttp://ADDRESS/something时单击,它将重定向到http://ADDRESS/something/first

怎样才能在ADDRESS之前获取重定向,但由于该值可能会更改而不能放置此值( ADDRESS )? (对于此示例,它应该获得http://ADRESS/firsthttp://ADDRESS/something/first

您要/first而不是first

没有斜杠,这是相对链接。 使用斜杠,绝对是基本URL。

<input type="submit" onclick="location.href='/first'" value="goSomewhere1"/>
<input type="submit" onclick="location.href='/second'" value="goSomewhere2"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM