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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵