HTTP协议改HTTPS

//获取源机器的协议

string protocol = Request.Url.AbsoluteUri.ToLower().IndexOf("https") != -1 ? "https://" : "http://";

//获取绝对路径

function getAbsoluteUrl(url) {
    var a = document.createElement('A');
    a.href = url; 
    url = a.href;  
    if (url.indexOf('/player/video.aspx') != -1) {
        return url.toLowerCase().replace("https", "http");
    }
    return url;
}

//替换http为https

function getprotocol(url) {
    var ishttps = 'https:' == document.location.protocol ? true : false;
    if (ishttps) {
        return url.replace("http://", "https://");
    } else {
        return url;
    }
}
原文地址:https://www.cnblogs.com/dennysong/p/7090053.html