窗口位置主题标签语法错误在问号后未读取
Window location hashtag syntax error not reading after question mark
我有以下代码,如果您像这样登陆带有主题标签和文本的页面,它可以正常工作#dashboard
- 它应该降落在主题标签#whatever
并滚动到该部分加载的位置。
$(document).ready(function() {
// *only* if we have anchor on the url
if (window.location.hash) {
var hashname = $(window.location.hash);
// smooth scroll to the anchor id
$('html, body').animate({
scrollTop: hashname.offset().top - 75
}, 500);
}
});
但是当你登陆这样的网址时
http://domain.com/#dasboard?utm_source=hubspot&utm_medium=ad&utm_campaign=stackoverflow
它将此错误输出Uncaught Error: Syntax error, unrecognized expression:
它在?
标记后不读取任何内容
我做错了什么?
主题标签是一个自动超链接的搜索词。您没有主题标签,您有一个片段标识符,但您没有正确实现它。
片段标识符位于 URL 中的查询字符串之后,而不是之前。
浏览器正在解析#dasboard?utm_source=hubspot&utm_medium=ad&utm_campaign=stackoverflow
作为您的选择器并遇到错误,因为您在其中有一个?
。
相关文章:
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- 未捕获的类型错误:无法读取属性'删除'的未定义
- 未捕获的类型错误:无法读取属性'name'即使它存在,也无法定义
- 看到“;未捕获的类型错误:无法读取属性'weight'未定义的“;尽管按照字面上的指示
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- 未捕获的类型错误:无法读取属性'addEventListener'的null chrome扩展名
- 未捕获的类型错误:无法读取属性'状态'在react中为null
- 未捕获的类型错误:无法读取属性'中止'的未定义
- Javascript未捕获类型错误:无法读取属性'0'的未定义
- jQuery控制台错误:无法读取属性'top'的未定义
- 未捕获的类型错误: 无法读取未定义的属性“图像”
- 我该如何解决这个问题?“未捕获的类型错误:无法读取 null 的属性'appendChild'”
- json-api和错误结果:无法读取属性'长度'的未定义
- VM5111:1249未捕获类型错误:无法读取属性'x'为null
- 未捕获的类型错误:无法读取属性'道具'reactJS中未定义的
- 类型错误:无法读取未定义的属性“toString” - 为什么
- 扩展程序读取错误的数据 + gt>不起作用
- PHP 套接字读取错误
- Websocket onerror - 如何读取错误描述
- Chrome 和 IE 上的 Javascript XML 读取错误