Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
191 views
in Technique[技术] by (71.8m points)

Simple jQuery code works fine until site is loaded via https://

I have a simple peice of jQuery code that submits a form and hides/shows some on screen information. It works fine when tested, until loaded via https:// upon which it breaks in IE7. It appears to break totally, with none of the script having any effect. I also get the IE warning that "some elements are insecure".

Does anyone have any experience of this happening? Or even better, a solution! I have to load the page via https as its a credit card payment page.

question from:https://stackoverflow.com/questions/1056497/simple-jquery-code-works-fine-until-site-is-loaded-via-https

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The three previous answers all mention the problem of a secured "https" page trying to include scripts or other resources (stylesheets, images, etc) from an "http" path...

I would like to add to these, and note that if you have a situation where the same pages could be loaded via either http or https, then you can create "protocol-less" URLs---the protocol will be assumed to be the same as the current page. Note this is only needed for accessing resources on different domains (and will only work if those different domains support both http and https), because obviously if you're accessing resources on the same domain, you don't need to start with http:// at all...

For example, each of these three resources would assume either http or https depending on how the current page was accessed:

<script src="//www.example.com/whatever.js" type="text/javascript"></script>
<img src="//www.example.com/someimage.png" alt="whatever" />
<link href="//www.example.com/styles.css" rel="stylesheet" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...