使用IE8中的http URL在https页面中导入js文件 [英] Importing js file in https page using http URL in IE8

查看:118
本文介绍了使用IE8中的http URL在https页面中导入js文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎在IE8中,
如果使用https协议的页面需要导入.js文件,
.js文件也需要使用https协议。

It seems that in IE8, if the page using https protocol needs to import a .js file, the .js file also needs to use the https protocol.

<script type="text/javascript" src="http://xxx/yourjs.js"></script> 

适用于除IE8以外的所有浏览器

works in all browsers except IE8

<script type="text/javascript" src="https://xxx/yourjs.js"></script> 

适用于所有浏览器

我是使用导入多个.js文件的usercontrol。这意味着如果一个页面使用https协议,那么我必须更改usercontrol,以便所有导入的.js文件都使用https协议。

I am using a usercontrol which imports several .js files. This means that if one page uses https protocol, then I have to alter the usercontrol so that all imported .js files are using https protocol.

如何解决此问题?

你如何评论这个IE8的行为?

How do you resolve this issue?
How do you comment on this IE8 behavior?

推荐答案

在HTTPS上使用它

<script type="text/javascript" src="http://xxx/yourjs.js"></script>

应该在所有浏览器中向用户发出警告 - 我希望IE8也能这样做但也许它是一个新的功能,默默地忽略它。

should throw up a warning to the user in all browsers - I'd expect IE8 to do the same but maybe it's a new "feature" to silently ignore it.

你应该使用与请求相同的协议,或者总是失败的HTTPS(尽管这将是对用户来说速度较慢,并且会给服务器带来更多负担。)

You should use the same protocol that the request is on, or failing that always HTTPS (though this will be slower for the user and put more load on your server).

您可以指定不带方案的URL - 应该使用当前的URL(http或https):

You could specify the URL without the scheme - that should use the current one (http or https):

<script type="text/javascript" src="//xxx/yourjs.js"></script>

编辑:找到有效的参考文献: RFC 2396

Found the reference saying this is valid: RFC 2396


 relativeURI   = ( net_path | abs_path | rel_path ) [ "?" query ]


开头的相对引用两个斜杠字符称为

网络路径引用,由第3节中的
定义。很少使用
引用。

A relative reference beginning with two slash characters is termed a
network-path reference, as defined by in Section 3. Such
references are rarely used.

这篇关于使用IE8中的http URL在https页面中导入js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆