环球免税店主题偶尔不加载

问题描述

| 我正在我的网站上使用galleria幻灯片放映,但我注意到似乎是随机发生的错误。大多数情况下,幻灯片可以正确加载,但有时我会收到以下错误消息:
 Uncaught Error: Fatal error: Theme at javascript/themes/classic/galleria.classic.js
 Could not load,check theme path.
重新加载页面后,一切恢复正常。 这是我用来加载它的代码
  <script> 
        // Load the classic theme
   galleria.loadTheme(\'javascript/themes/classic/galleria.classic.js\');
    </script> 
我到处搜寻,但仍未找到有效的解决方案。我个人的想法是拥有一个脚本,该脚本会一直加载直到成功为止,因为重新加载页面后即可正常工作。 我该怎么做?     

解决方法

        1在gihub上尝试最新版本:https://github.com/aino/galleria/blob/master/src/galleria.js 2尝试使用脚本标签加载主题:
<script src=\"javascript/themes/classic/galleria.classic.js\"></script>
    ,        今天,当我尝试使用Galleria时,我也收到了类似的消息。它仅在Firefox中发生。为了解决这个问题,我直接在
head
中添加了主题样式表链接。在样式表之后,我也保留了主题脚本链接,以防万一。在那之后,错误消息消失了,Galleria正在正常工作。     ,        从错误消息的来源来判断,并考虑随机发生的情况,此问题可能是由于加载时简单地达到了超时而造成的:
Galleria.loadTheme = function( src,options ) {

var loaded = false,length = _galleries.length,err = window.setTimeout( function() {
        Galleria.raise( \"Theme at \" + src + \" could not load,check theme path.\",true );
    },5000 );
在版本1.2.2中,超时仅为2秒,在上述(1.2.6)中,超时为5秒。因此,绝对可以尝试升级到更高版本或自定义超时。     ,        我采用了David指出的方法,使用脚本标签加载了主题:
<script src=\"javascript/themes/classic/galleria.classic.js\"></script>
但是最终还是收到另一个错误(致命错误:20秒后无法加载主题CSS)。我还建议您使用链接标记添加CSS:
<link rel=\"stylesheet\" type=\"text/css\" href=\"galleria/themes/classic/galleria.classic.css\" />
    ,        给定随机行为,感觉就像是浏览器错误。更具体地说,浏览器会失去对基本URL的跟踪。我会提供来自webroot的完整路径,看看错误是否消失了。例如:
Galleria.loadTheme(\'/gallery/javascript/themes/classic/galleria.classic.js\');
如果这样做没有帮助,请尝试:
try {
    Galleria.loadTheme(\'javascript/themes/classic/galleria.classic.js\');
}
catch(e) {
    location.reload();
}
但这可以无限进行。我会尽力找出错误的根源,并从不同的浏览器开始,以排除代码中的错误。     ,        初学者指南指出,加载主题的脚本标签必须位于html源代码中的图像之后。您可能已经在head标签中添加了script标签。指南中的示例:
<body>
    <div id=\"galleria\">
        <img src=\"photo1.jpg\">
        <img src=\"photo2.jpg\">
        <img src=\"photo3.jpg\">
    </div>
    <script>
        Galleria.loadTheme(\'galleria/themes/classic/galleria.classic.min.js\');
        Galleria.run(\'#galleria\');
    </script>
</body>
    

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...