如何从https将URL发送到非SSL服务器

时间:2014-07-31 02:54:56

标签: jquery ajax ssl

我有一台服务器正在运行控制我的电视,我希望能够使用书签将链接推送到它。现在,一切都运行得很好,除非我试图将https链接推送到它。

这里是小书签代码:

(function(){

    // the minimum version of jQuery we want
    var v = "1.3.2";

    // check prior inclusion and version
    if (window.jQuery === undefined || window.jQuery.fn.jquery < v) {
        var done = false;
        var script = document.createElement("script");
        script.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + v + "/jquery.min.js";
        script.onload = script.onreadystatechange = function(){
            if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
                done = true;
                initMyBookmarklet();
            }
        };
        document.getElementsByTagName("head")[0].appendChild(script);
    } else {
        initMyBookmarklet();
    }

    function initMyBookmarklet() {
        (window.myBookmarklet = function() {
            $.ajax({
                url: "http://192.168.1.2:4567",
                type: "GET",
                data: {url: "http://" + document.URL.replace(/https?:\/\//i, "")},
                dataType: "jsonp"
            });
        })();
    }

})();

问题是http://192.168.1.2:4567不是https网址,因此当尝试在任何https网站上执行此书签时,我收到以下错误:

[blocked] The page at 'https://www.youtube.com/watch?v=S-rM3FRlt9o' was loaded over HTTPS, but ran insecure content from 'http://192.168.1.2:4567/?callback=jsonp1406774222812&_=1406774936255&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DS-rM3FRlt9o': this content should also be loaded over HTTPS.

有没有办法绕过这个使用javascript?

0 个答案:

没有答案