[英]Script link formatting for cross-browser compatibility
I'm referencing the following scripts in the header of https://livingibogaine.squarespace.com . 我在https://livingibogaine.squarespace.com的标题中引用了以下脚本。 I'd post the HTML separately, but it's mountainous.
我将单独发布HTML,但是它是多山的。
The scripts trigger great in Safari! 这些脚本在Safari中触发效果非常好! Firefox and Chrome don't read them at all.
Firefox和Chrome根本不阅读它们。 Am I formatting them incorrectly?
我格式化不正确吗? Or this likely a bug in the Squarespace platform?
还是这可能是Squarespace平台中的错误?
<link rel="stylesheet" type="text/css" href="http://www.wlvrtn.com/sites/www.livingcleanibogaine.com/css/style-five.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="http://www.wlvrtn.com/sites/www.livingcleanibogaine.com/js/jquery.sticky.js"></script>
<script type="text/javascript">
$(window).load(function(){
$("#page-nav").sticky({ topSpacing: 0 });
});
</script>
<script type="text/javascript">
$(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
}, 800);
return false;
}
}
});
});
</script>
This is possibly because you are loading the page over https
, but your scripts over http
. 这可能是因为您是通过
https
加载页面,但通过http
加载了脚本。 Chrome can be a bit fussy about doing insecure things like that. Chrome可能会对这样不安全的事情有些挑剔。 Try changing the jQuery link to
src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
and access your jquery.sticky.js
file from an https site also. 尝试将jQuery链接更改为
src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
并从https站点访问jquery.sticky.js
文件。
EDIT: jquery.sticky.js is hosted on a https CDN here - https://cdn.jsdelivr.net/jquery.sticky/1.0.0/jquery.sticky.min.js 编辑:jquery.sticky.js托管在一个HTTPS CDN在这里- https://cdn.jsdelivr.net/jquery.sticky/1.0.0/jquery.sticky.min.js
Try using the following code: 尝试使用以下代码:
<script type="text/javascript">
jQuery(window).load(function($){
$("#page-nav").sticky({ topSpacing: 0 });
});
</script>
<script type="text/javascript">
jQuery(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
}, 800);
return false;
}
}
});
});
</script>
See also @JoshLowry answer 另请参阅@JoshLowry答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.