我对于这个控制台错误有点头疼,仅在Safari上才可以(实际上是在MacBook上工作)。
我有这个功能:
function exists(element){
var exists = document.querySelector(element);
return exists;
}
Run Code Online (Sandbox Code Playgroud)
在另一个函数内部调用:
function includeHoverStylesheet(){
var path = $("body").attr("data-hover");
if (!("ontouchstart" in document.documentElement || exists("link[href='" + path + "'"))) {
var link = document.createElement("link");
link.rel = "stylesheet", link.href = path, document.head.appendChild(link) && document.body.removeAttribute("data-hover");
}
}
Run Code Online (Sandbox Code Playgroud)
现在,在Chrome上像超级按钮一样工作,但是在Safari上,控制台会抛出此错误:
1) Invalid CSS property declaration at: *
2) jQuery.Deferred exception: The string did not match the expected pattern.
3) SyntaxError (DOM Exception 12): The string did not match the expected pattern.
Run Code Online (Sandbox Code Playgroud)
有人知道发生了什么事吗???
在此先感谢大家!
safari syntax-error jquery-deferred safari-web-inspector jquery-3