How to use Google Custom Search on https to avoid

2019-04-27 18:24发布

Is there a way to get the script for search results from an HTTPS site instead of http://www.google.com/afsonline/show_afs_search.js

I am using the custom google business search on a HTTPS site. When search is submitted web browser shows warning:

"This page contains both secure and nonsecure items"

I tried to modify the source to be https://www.google.com/afsonline/show_afs_search.js but that doesn't work. Still JavaScript returned from that link connects to http links instead of https links.

Does anybody knows how to fix this ?

3条回答
劳资没心,怎么记你
2楼-- · 2019-04-27 19:01

A hack that works for me is to provide a modified version of the script

https://www.google.com/afsonline/show_afs_search.js

on another server, say:

https://www.myserver.com/show_afs_search.js

Just copy the original scripts source code and replace 'http' with 'https' in the script (one occurrence). Of course that might stop working anytime if Google changes something.

查看更多
狗以群分
3楼-- · 2019-04-27 19:03

Even if you modify the Javascript link to HTTPS, show_afs_search.js is still hardcoded to get the search results via HTTP, not HTTPS. To avoid this error, make your own copy of show_afs_search.js that grabs results via HTTPS.

Steps:

  1. download show_afs_search.js
  2. open the file and replace 'http' with 'https'
  3. put this file one your https server and use it
查看更多
该账号已被封号
4楼-- · 2019-04-27 19:18

Just change the one instance of http to https.

查看更多
登录 后发表回答