簡體   English   中英

將jQuery與WordPress主題一起使用時出錯

[英]Error when using jQuery with WordPress theme

我購買了WordPress主題,並已開始對其進行自定義。 在我的一生中,該主題的一個方面我無法弄清楚為什么它重定向到名為“ undefined”的頁面。

sdndaily.com是有問題的網站。

!function (a, b) {
'object' == typeof module && 'object' == typeof module.exports ? module.exports = a.document ? b(a, !0)  : function (a) {
    if (!a.document) throw new Error('jQuery requires a window with a document');
    return b(a)
}
 : b(a)
}('undefined' != typeof window ? window : this, function (a, b) {
var c = [
],
d = c.slice,
e = c.concat,
f = c.push,
g = c.indexOf,
h = {
},
i = h.toString,
j = h.hasOwnProperty,
k = {
},
l = '1.11.1',
m = function (a, b) {
    return new m.fn.init(a, b)
}

右上角有一個信封圖標,該信封圖標使用JavaScript下拉部分以插入您的電子郵件。 單擊它后不久,您將被重定向到標題為“ undefined”的頁面,螢火蟲吐出一個錯誤:

Error( "jQuery requires a window with a document" );

最簡單的解決方案是將下面的標簽變成跨度。 我在您的網站上對此進行了測試,它的工作原理很吸引人:

<div id="collapse-trigger">
    <a data-toggle="collapse" class="collapse collapsed" data-target="#newsletter">
    <i class="icon-envelope-alt"></i>   </a>
</div>

成為:

<div id="collapse-trigger">
    <span data-toggle="collapse" class="collapse collapsed" data-target="#newsletter">
    <i class="icon-envelope-alt"></i>   </span>
</div>

或者,找到動作處理程序JS函數,並添加事件參數和event.preventDefault();。 在功能之上:

$('your_selector').click(function(event) {
    event.preventDefault();

    ...
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM