[英]Append programmatically current anchor/hash/fragment to any form action url with Javascript/jQuery
[英]Is there a way to append a fragment to the current URL
on the server in PHP (Or I guess another language; JavaScript perhaps)? 我对PHP相对较新,我想知道是否可以在PHP服务器上使用修改当前的URL(或者我猜是另一种语言;也许是JavaScript)?
谢谢你的帮助,
Abarnybox
用JavaScript
window.location=window.location+'#something'
用PHP
$query = parse_url($url, PHP_URL_QUERY);
if ($query) {
$url .= '#something';
}
另一种最简单的方法是在当前网址中添加#something
JS:
var e = "something";
window.history.pushState(" ", "", "#" + e)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.