根据https更改src引用
我正在向网站添加 Facebook 评论小部件。我将此小部件放置在每个页面都包含的文件中。导航是相对链接的,所以会在http和https之间来回切换。但由于某种原因,只有当 src 链接文件和网页都是安全的或者 src 链接文件和网页都不安全时,评论小部件才会显示。小部件不显示 src 文件是安全的,而网页是不安全的。所以...我已经尝试过但不起作用。
if (window.location.protocol == 'https:')
script.setAttribute('src', 'https:// /ssl.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php');
}
否则
{
script.setAttribute('src', 'http://static.ak.connect .facebook.com/connect.php/en_US')
}
I'm adding a facebook comment widget to a website. I'm placing this widget in a file that is included on everypage. The navigation is relatively linked so it switches back and forth from http and https. But for some reason the comment widget only shows up if both the src linked file and webpage is secure or both the src linked file and webpage is NOT secure. The widget does not display of the src file is secure and the webpage is not secure. So... I've tried this but doesn't work.
if (window.location.protocol == 'https:')
script.setAttribute('src', 'https://ssl.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php');
}
else
{
script.setAttribute('src', 'http://static.ak.connect.facebook.com/connect.php/en_US')
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法更改现有的脚本标签,只能创建新的脚本标签。
You can't change existing script tags, only make new ones.