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