0
我想添加一個JS代碼到我的模板,但我收到安全錯誤:如何修復MyBB的JavaScript錯誤
一個潛在的安全問題是在模板中找到。請檢查您的更改或聯繫MyBB小組尋求支持。
代碼:
//Start navbar toggle fix top bottom
$(document).on('click', '.toggle_fixing', function(e) {
e.preventDefault();
if ($('#main_navbar').hasClass('navbar-fixed-top')) {
$('#main_navbar').toggleClass('navbar-fixed-bottom navbar-fixed-top');
$(this).children('i').toggleClass('fa-chevron-down fa-chevron-up');
} else {
$('#main_navbar').toggleClass('navbar-fixed-bottom');
$(this).children('i').toggleClass('fa-chevron-down fa-chevron-up');
if ($('#main_navbar').parent('div').hasClass('container')) $('#main_navbar').children('div').addClass('container').removeClass('container-fluid');
else if ($('#main_navbar').parent('div').hasClass('container-fluid')) $('#main_navbar').children('div').addClass('container-fluid').removeClass('container');
FixMegaNavbar(navHeight);
}
if ($('#main_navbar').hasClass('navbar-fixed-top')) {$('body').css({'margin-top': $('#main_navbar').height()+'px', 'margin-bottom': ''});}
else if ($('#main_navbar').hasClass('navbar-fixed-bottom')) {$('body').css({'margin-bottom': $('#main_navbar').height()+'px', 'margin-top': ''});}
})
//End navbar toggle fix top bottom
//Start Fix MegaNavbar on scroll page
var navHeight = $('#main_navbar').offset().top;
FixMegaNavbar(navHeight);
$(window).bind('scroll', function() {FixMegaNavbar(navHeight);});
function FixMegaNavbar(navHeight) {
if (!$('#main_navbar').hasClass('navbar-fixed-bottom')) {
if ($(window).scrollTop() > navHeight) {
$('#main_navbar').addClass('navbar-fixed-top')
$('body').css({'margin-top': $('#main_navbar').height()+'px'});
if ($('#main_navbar').parent('div').hasClass('container')) $('#main_navbar').children('div').addClass('container').removeClass('container-fluid');
else if ($('#main_navbar').parent('div').hasClass('container-fluid')) $('#main_navbar').children('div').addClass('container-fluid').removeClass('container');
}
else {
$('#main_navbar').removeClass('navbar-fixed-top');
$('#main_navbar').children('div').addClass('container-fluid').removeClass('container');
$('body').css({'margin-top': ''});
}
}
}
//End Fix MegaNavbar on scroll page
//Next code used to prevent unexpected menu close when using some components (like accordion, tabs, forms, etc), please add the next JavaScript to your page
$(window).load(function() {
$(document).on('click', '.navbar .dropdown-menu', function(e) {e.stopPropagation();});
});
我怎樣才能解決這個問題?
我將此代碼添加到外部文件。但它沒有奏效。當我刪除這部分時,一些函數正在工作://在滾動頁面上啓動Fix MegaNavbar var navHeight = $('#main_navbar')。offset()。top; FixMegaNavbar(navHeight); $(window).bind('scroll',function(){FixMegaNavbar(navHeight);}); –
模板中是否找到了_A潛在的安全問題。請檢查您的更改或聯繫MyBB小組獲取支持。如果是這樣,我建議將此標記爲已回答並用javascript標記創建一個新問題。如果你打開JavaScript控制檯,是否有任何錯誤? –