简体   繁体   English

顶部菜单显示一个空白选项,将我重定向到未定义的页面。 我该如何解决?

[英]Top menu showing a blank option which redirects me to an undefined page. How can I fix it?

I have a blog site which has some issues. 我有一个博客网站有一些问题。 When you will try to open my blog in a smartphone or zoom it to 300%, you will see the top menu turn into a drop-down menu which has a blank option on the second place of it. 当您尝试在智能手机中打开我的博客或将其缩放到300%时,您会看到顶部菜单变成一个下拉菜单,其第二位有一个空白选项。 When anyone clicks it, it redirects to a 404 Error Page. 当任何人点击它时,它会重定向到404错误页面。 Please help me to fix this error. 请帮我修复此错误。

I am attaching some images for reference. 我附上一些图片供参考。

Screenshot showing menu without blank option 屏幕截图显示没有空白选项的菜

Screenshot showing menu with blank option 屏幕截图显示带有空白选项的菜

Screenshot showing 404 Error Page 屏幕截图显示404错误页面

I will also add the menu bar code with it. 我还将添加菜单条形码。

// Plugin: SelectNav.js ~ url: https://github.com/lukaszfiszer/selectnav.js window.selectnav=function(){"use strict";var e=function(e,t){function c(e){var t;if(!e)e=window.event;if(e.target)t=e.target;else if(e.srcElement)t=e.srcElement;if(t.nodeType===3)t=t.parentNode;if(t.value)window.location.href=t.value}function h(e){var t=e.nodeName.toLowerCase();return t==="ul"||t==="ol"}function p(e){for(var t=1;document.getElementById("selectnav"+t);t++);return e?"selectnav"+t:"selectnav"+(t-1)}function d(e){a++;var t=e.children.length,n="",l="",c=a-1;if(!t){return}if(c){while(c--){l+=o}l+=" "}for(var v=0;v"+l+g+"";if(s){var b=e.children[v].children 1 ;if(b&&h(b)){n+=d(b)}}}}if(a===1&&u){n=''+u+""+n}if(a===1){n=''+n+""}a--;return n}e=document.getElementById(e);if(!e){return}if(!h(e)){return}if(!("insertAdjacentHTML"in window.document.documentElement)){return}document.documentElement.className+=" js";var n=t||{},r=n.activeclass||"active",i=typeof n.autoselect==="boolean"?n.autoselect:true,s=typ //插件:SelectNav.js~url: https//github.com/lukaszfiszer/selectnav.js window.selectnav = function(){“use strict”; var e = function(e,t){function c(e ){var t; if(!e)e = window.event; if(e.target)t = e.target;否则if(e.srcElement)t = e.srcElement; if(t.nodeType === 3) )t = t.parentNode; if(t.value)window.location.href = t.value} function h(e){var t = e.nodeName.toLowerCase(); return t ===“ul”|| t ===“ol”}函数p(e){for(var t = 1; document.getElementById(“selectnav”+ t); t ++); return e?“selectnav”+ t:“selectnav”+(t -1)}函数d(e){a ++; var t = e.children.length,n =“”,l =“”,c = a-1; if(!t){return} if(c){ while(c - ){l + = o} l + =“”} for(var v = 0; v“+ l + g +”“; if(s){var b = e.children [v] .children 1 ;如果(b && 11(b)){N + = d(b)}}}}如果(一个=== 1 && U){N = '' + U + “” + n}如果(一个=== 1){N =” '+ n +“”} a - ; return n} e = document.getElementById(e); if(!e){return} if(!h(e)){return} if(!(“insertAdjacentHTML”在窗口中) .document.documentElement)){return} document.documentElement.className + =“js”; var n = t || {},r = n.activeclass ||“active”,i = typeof n.autoselect ===“boolean “n.autoselect:真,S =(典型值) eof n.nested==="boolean"?n.nested:true,o=n.indent||"-",u=n.label||"Menu",a=0,f=" selected ";e.insertAdjacentHTML("afterend",d(e));var l=document.getElementById(p());if(l.addEventListener){l.addEventListener("change",c)}if(l.attachEvent){l.attachEvent("onchange",c)}return l};return function(t,n){e(t,n)}}(); eof n.nested ===“boolean”?n.nested:true,o = n.indent ||“ - ”,u = n.label ||“Menu”,a = 0,f =“selected”; e .insertAdjacentHTML(“afterend”,d(e)); var l = document.getElementById(p()); if(l.addEventListener){l.addEventListener(“change”,c)} if(l.attachEvent){ l.attachEvent(“onchange”,c)} return l}; return function(t,n){e(t,n)}}();

You can add this script to your website. 您可以将此脚本添加到您的网站。 I tested with chrome debug tool and it worked. 我用chrome调试工具测试过它。

When you resize browser or use in ipad/iphone, it will trigger code to remove options have undefined 当您调整浏览器大小或在ipad / iphone中使用时,它将触发代码以删除未定义的选项

$(window).resize(function(){
    if ($(window).width()< 992){
      $('.selectnav option').each(function(index,item){ 
        if($(item).val() == "undefined"){ $(this).remove();}
      });
    }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复我的博客的顶部菜单栏显示空白? - How to fix top menu bar of my blog that is showing a blank space? jQuery脚本将我带到了页面顶部。 如何修改呢? - jQuery script takes me on top of page. How to modify this? 当我页面上的内容不适合屏幕时,它会移动页面的 rest。 我怎样才能解决这个问题? - When the content on my page doesn't fit the screen, it moves the rest of the page. How can I fix this? 通过书签设置新的innerHTML会删除整个页面。 我该如何解决? - seting new innerHTML via bookmarklets removes the whole page. How can I fix that? 灯箱2在另一页中打开图像。 我该如何解决? - Lightbox 2 opens images in another page. How do I fix this? jQuery单击将我带到页面顶部。 但我想留在原地 - jQuery click brings me to top of page. But I want to stay where I am Bootstrap Modals将我重定向到空白页 - Bootstrap Modals to redirects me to a blank page 我如何防止链接将我发送到页面顶部 - How can i prevent from link to send me to the top of the page jQuery发送到e,然后我可以使用e.currentTarget来获取页面上的元素。 我该如何使用它? - jQuery sends to e, which I can then use e.currentTarget to grab the element on the page. How do I then use it? 我想在我的PHP页面的选择菜单中的选择选项上添加一些文本框。 这应该是动态的(没有展开页面) - I want to add some textboxes on selecting option from select menu in my PHP Page. This should be Dynamically(without reloding page)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM