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 echarts动画效果失效的问题。官网下载的例子。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加