开发者

SSL Invalidated by Javascript

I have a webpage that requires SSL, but this one line of Javascript appears to invalidate the SSL encryption. Is there any way to stop this line from executing if the page requires SSL?

va开发者_StackOverflow中文版r api_url ="http://books.google.com/books?...";

That line is the problem....Google Books does not allow SSL connections.


The line you've quoted only assigns a value to a variable - it doesn't actually make a request. ASSUMING you've closed the string in your real code:

var api_url="http://books.google.com/books";

then it won't generate an error. Also, if you're making an AJAX request to Books, you specify the complete URL (including the protocol [http|https]), so the fact that the page that's hosting the JavaScript was retrieved via SSL shouldn't make a difference.

Post some of the surrounding code so we can see what's happening.


In your Javascript check document.location.protocol, for example:

if (document.location.protocol != 'https:')
{
    var api_url ="http://books.google.com/books? 
}


This will return true if client browser is using SSL on current location, false otherwise:

document.location.protocol == 'https:'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜