dtwvr26066 2019-05-05 11:04
浏览 84
已采纳

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

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. When anyone clicks it, it redirects to a 404 Error Page. 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

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].children1;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=typeof 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)}}();

  • 写回答

1条回答 默认 最新

  • duanjiangzhi6851 2019-05-05 11:43
    关注

    You can add this script to your website. I tested with chrome debug tool and it worked.

    When you resize browser or use in ipad/iphone, it will trigger code to remove options have undefined

    $(window).resize(function(){
        if ($(window).width()< 992){
          $('.selectnav option').each(function(index,item){ 
            if($(item).val() == "undefined"){ $(this).remove();}
          });
        }
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题
  • ¥15 求C# .net4.8小报表工具
  • ¥15 安装虚拟机时出现问题
  • ¥15 Selenium+docker Chrome不能运行
  • ¥15 mac电脑,安装charles后无法正常抓包
  • ¥18 visio打开文件一直显示文件未找到