我有这样的URL:http://example.com#something如何删除#something,而不会导致页面刷新?
我尝试了以下解决方案:
window.location.hash = '';
Run Code Online (Sandbox Code Playgroud)
但是,这不会#从URL中删除哈希符号.
这里有人使用Response.Redirect()方法,你是否在浏览器地址栏上遇到了一些附在uri末尾的奇怪字符?
奇怪的字符是哈希,下划线,等号和下划线(没有空格),如下面......我不知道这些是什么,当这些奇怪的字符出现时,重定向没有正确发生.
#_=_
Run Code Online (Sandbox Code Playgroud)
有关此问题的任何见解请分享.谢谢
我写了一个带有覆盖的弹出窗口(与通常的图片显示器不同),用户点击该窗口,并且覆盖层覆盖了用于显示的大图片的屏幕.
问题是,当用户点击"关闭"时,我的功能会淡化图片并覆盖,然后将其删除.当我调用该.remove()函数时,浏览器会关注body标签并滚动到页面顶部.
我尝试通过捕获offset.topco-ords并将它们存储在用户点击的元素的属性中,以及弹出窗口关闭时和之后的方法来进行解决.remove()我已经调用了scrollTo()函数,我使用该函数返回正确的滚动位置(由于某种原因,它会过冲并将元素滚动到顶部).
/*creating the popup layer and picture*/
function newsPopup(obj){
/***PART ZERO - get the timestamp value of this ***/
var itemID = $(obj).attr('itemID');
var storyNumber = $(obj).attr('storyNumber');
/*adding the identifier for later*/
var offset = $(obj).offset();
var roundedOff = Math.round(offset.top);
$(obj).attr('scrollMeBack', roundedOff);
/*** the script then continues to create an overlay and picture popup
}
/*function to remove popup*/
function overlayRemove(){
//first fade out the cover and the container
$("#NEWS_overlay").fadeOut(); …Run Code Online (Sandbox Code Playgroud)