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;
    }
}

 

posted @ 2017-06-28 15:48  楊柳  阅读(2701)  评论(0编辑  收藏  举报