【发布时间】:2025-12-27 02:55:15
【问题描述】:
我不确定为什么会一直这样。我搜索了如何从 URL 中删除主题标签并找到了很多答案。他们都没有帮助,因为他们只是删除了标签,但我不得不刷新页面。即便如此,这仍然没有帮助。我的问题是当我点击这个锚标签时会出现主题标签:
echo '<a href="?id='.$row['id'].'" <-- here is what I am trying to add to the URL, but the hashtag appears. id="smallbtn" data-toggle="modal" data-target="#small" data-modal="small">';
这是我用来尝试解决问题的 javascript,但没有成功(在 <head> 中也被告知要使用它。):
<script type="text/javascript">
// remove fragment as much as it can go without adding an entry in browser history:
window.location.replace("#");
// slice off the remaining '#' in HTML5:
if (typeof window.history.replaceState == 'function') {
history.replaceState({}, '', window.location.href.slice(0, -1));
}
</script>
而且我不知道是不是这个问题,但是我用这个打开了modal,把锚标签href放到了URL中:
<script type="text/javascript">
$(document).ready(function(){
$(window.location.hash).modal('show');
$('a[data-toggle="modal"]').click(function(){
window.location.hash = $(this).attr('href');
});
});
</script>
我的目标是尝试将该 href 作为参数放在 URL 中,但到目前为止,我很难让它发挥作用。非常感谢您对此的任何帮助!
【问题讨论】:
-
你需要
href="?id='.$row['id'].'"的id吗?如果不需要,请输入href=javascript:void(0) -
@MohsinMarui 哦,是的,我确实需要身份证。我在我的 php.ini 中使用 GET 方法。不过谢谢你的回答。
标签: javascript jquery html anchor href