简体   繁体   English

WordPress Javascript / jQuery无法在Webkit上运行

[英]Wordpress Javascript/jQuery not working on webkit

I have installed the plugins Easy Smooth Scroll Links (ESSL) and Page Scroll to ID for wordpress however neither of them seem to work on webkit browsers. 我已经安装了用于Wordpress的Easy Easy Scroll Links(ESSL)和Page Scroll to ID插件,但是它们似乎都无法在Webkit浏览器上工作。 I have done some research and have found at least one viable solution but the plugin files are in minified form, so it's almost impossible for me to modify them without spending hours re-formatting (there is also the fact that a majority of the code looks to be too advanced for me to understand.) 我进行了一些研究,找到了至少一个可行的解决方案,但是插件文件采用的是缩小格式,因此,几乎不花时间重新格式化就几乎不可能修改它们(还有一个事实是,大多数代码看起来对我来说太先进了。)

If it is any help the site I am working on is http://design.mindgarden.me/ and the section in question is the circle/down arrow button. 如果对我正在工作的站点有帮助,请访问http://design.mindgarden.me/ ,相关部分为圆圈/向下箭头按钮。 Upon clicking/pressing it, it should scroll the page down to the services section. 单击/按下后,它应将页面向下滚动到服务部分。 (Works fine on Firefox, IE and presumably other non-webkit browsers but not on Chrome, Safari, etc.) (在Firefox,IE和大概其他非Webkit浏览器上都可以正常工作,但在Chrome,Safari等上不能正常工作)

Anyway the main answer I am trying to get to here is (if this is a well known enough issue) if there is any known work around/fix or if there is an alternative plugin with the same functionality that you know of which works on webkit browsers. 无论如何,我要解决的主要问题是(如果这是一个众所周知的问题)是否存在已知的解决方法/修复方法,或者是否存在与您在webkit上都能使用的功能相同的替代插件浏览器。

I have already submitted a support ticket modernthemes (creator of the theme I am using as I had previously thought it was an issue on their side) however seeing as we are in different hemispheres I figured I would try to reach out to a wider audience. 我已经提交了一张现代主题的支持票(我曾经使用的主题创建者,以前我认为这是他们的问题),但是看到我们处在不同的半球时,我想我会尝试接触更多的受众。 I have also checked the support forums for each plugin I mentioned, however there was no such topic posted and they seemed pretty inactive... also a search on wordpress for similar plugins only revealed hundreds of "scroll to top" clones which is not what I am looking for at the moment. 我还检查了我提到的每个插件的支持论坛,但是没有发布这样的主题,而且它们似乎还很不活跃...在wordpress上搜索类似的插件也只发现了数百个“从头到尾”的克隆,这不是什么。我目前正在寻找。 And now that I think about it, I may as well post a thread about this on the official wordpress support forums... 现在我考虑了一下,我不妨在官方的WordPress支持论坛上发布有关此主题的主题...

Thank you in advance. 先感谢您。

Ps. 附言 It says I need at least 10 reputation to post more than 2 links, so you will have to google for the plugins yourself. 它说我需要至少10个信誉才能发布2个以上的链接,因此您将不得不自己搜索Google插件。

You could just use something like this: 您可以只使用以下内容:

<script>
$(function() {
  $('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {

      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top
        }, 1000);
        return false;
      }
    }
  });
});
</script>

I found it here on CSS tricks, you can see a working example and inspect element to see how the markup looks. 我在CSS技巧上找到了它,您可以看到一个有效的示例并检查元素以查看标记的外观。 https://css-tricks.com/examples/SmoothPageScroll/ For incorporating into WordPress, you can simply add the code to your footer.php, or add the your main script file for you theme. https://css-tricks.com/examples/SmoothPageScroll/要整合到WordPress中,您只需将代码添加到footer.php中,或添加主题的主脚本文件即可。 Let me know if you have any questions, and I will help walk you through it. 如果您有任何问题,请告诉我,我们将助您一臂之力。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM