我有这个网址 http://localhost:1234/pag1
当我点击div时,我想要的效果如下:
http://localhost:1234/pag1?fare=standar
我有一个onclick事件函数:
<div id="" onclick="addUrl();"> </div>
以下是JavaScript代码:
<script type="text/javascript">
function addUrl() {
var url = window.location.href;
window.location.hash = '?fare=standar';
};
</script>
这给我带来了这个结果:
http://localhost:1234/pag1#?fare=standar
我不知道如何去掉 (#)。我只需要在URL中添加参数,而不刷新页面。
给我建议!谢谢。