[英]Script loads a function before I call it locally but publicly it loads it after
Sorry for the confusing title, but my sidenav on my portfolio website opens when I run the html page. 抱歉,标题令人困惑,但是当我运行html页面时,我在我的投资组合网站上的sidenav打开。 When I use it on my website, it just says
Uncaught ReferenceError: openNav is not defined at HTMLSpanElement.onclick ((index):23) onclick @ (index):23
which just leads me to where I'm calling the function. 当我在网站上使用它时,它只是说出
Uncaught ReferenceError: openNav is not defined at HTMLSpanElement.onclick ((index):23) onclick @ (index):23
上Uncaught ReferenceError: openNav is not defined at HTMLSpanElement.onclick ((index):23) onclick @ (index):23
,这仅将我引向了我调用函数的地方。 Is it because I'm loading the script after I call it? 是因为调用后我正在加载脚本吗? How come it works locally though?
它如何在本地运作?
Also I have my server going through Cloudflare if that's any help. 如果有什么帮助,我也可以让我的服务器通过Cloudflare。 I've also already tried uploading my local files and replacing the ones on the server completely, they were the exact same though.
我也已经尝试上传本地文件并完全替换服务器上的文件,尽管它们完全相同。
One more also, I have the page on Github Pages as well and it works fine. 另外,我在Github Pages上也有该页面,并且工作正常。 Github Pages
Github页面
EDIT: Relevent Code?: 编辑:释放代码?:
$(function(){$('[data-toggle="tooltip"]').tooltip();});$('.tool-tip').click(function(e){e.preventDefault();});const openNav=()=>{if($(window).width()>2000){document.getElementById("mySideNav").style.width="750px";}else{document.getElementById("mySideNav").style.width="250px";} document.getElementById("navTextWrapper").style.display="block";} const closeNav=()=>{document.getElementById("mySideNav").style.width="0";document.getElementById("navTextWrapper").style.display="none";}
<span class="openMenu" onclick="openNav();">☰</span> <nav id="mySideNav" class="sidenav"> <div id="navTextWrapper"> <div class="navBrandExit"> <a href="#" class="brand">Kenneth Rhodes</a><a href="#" class="closeBtn" onclick="event.preventDefault(); closeNav();">×</a> </div> <a href="#showcase">Top</a> <a href="#perks">Skills</a> <a href="#portfolio">Portfolio</a> <a href="#contact">Contact</a> </div> </nav>
Checking your website it seems js/main.js is not being loaded properly, can you try turning off Rocket Loader in cloudflare Performance Settings to see if it has any impact? 检查您的网站,似乎js / main.js没有正确加载,您可以尝试在cloudflare Performance Settings中关闭Rocket Loader看看是否有影响吗? You can get to your Performance Settings by going to:
您可以通过以下方法进入“性能设置”:
Speed > Rocket loader 速度>火箭装载机
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.