2011-12-16 116 views
0

我正在使用FancyApp从FancyApps预览我的网站上的内容。Jquery https http问题

<a href="#inline" class="various"><span class="info"></span></a> 

<div id="inline" style="display:none;width:500px;"> 
    <h2>Always enjoy the sunny days!</h2> 
</div> 

<script type="text/javascript"> 
    $(document).ready(function() { 
     $(".various").fancybox({ 
       maxWidth : 500, 
       autoSize : true, 
       closeClick : false, 
       openEffect : \'none\', 
       closeEffect : \'none\' 
      }); 
    }); 
</script> 

基本上这是工作的罚款,但在一种情况下,我需要我的网站重定向到安全服务器,所以该域名将改变。

例子:

https://secure-payment.com/relay/v2/relay.cgi/http://www.mydomain.com/checkout

当我使用的链接触发的fancybox没有这个页面,我只是得到“ 请求的内容无法加载,请稍后重试

另外(我不知道它是否相关)我在页面底部运行下面的脚本,这是根据付款公司的要求。

// 
// Variables used for searching 
// 
var relayurl = "https://relay.ditonlinebetalingssystem.dk/"; 
var relayurl_replace = "https://relay.ditonlinebetalingssystem.dk/relay/v2/relay.cgi/"; 
var baseurl = ""; 

function getURLParam(strParamName){ 
    var strReturn = ""; 
    var strHref = window.location.href; 
    if (strHref.indexOf("?") > -1){ 
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase(); 
    var aQueryString = strQueryString.split("&"); 
    for (var iParam = 0; iParam < aQueryString.length; iParam++){ 
     if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1){ 
     var aParam = aQueryString[iParam].split("="); 
     strReturn = aParam[1]; 
     break; 
     } 
    } 
    } 
    return unescape(strReturn); 
} 

// 
// Replace all links to NOT use the relay-script when the user clicks on the links 
// 
function replaceRelayButtons(parent, startTimer) { 
    var aEls = parent.childNodes; 
    for (var i = 0, aEl; aEl = aEls[i]; i++) { 
     // 
     // Do recursive call 
     // 
     replaceRelayButtons(aEls[i]); 

     if (aEls[i].tagName == 'A' || aEls[i].tagName == 'a') { 
      if (aEls[i].href.indexOf(relayurl) == 0) { 
       aEls[i].href = aEls[i].href.replace(relayurl_replace, ""); 
       aEls[i].href = aEls[i].href.replace(relayurl, "") 
       if (aEls[i].href.indexOf("http://") != 0) { 
        aEls[i].href = (baseurl + "/" + aEls[i].href); 
       } 
      } 
     } 
     if (baseurl.length > 0) { 
      if (aEls[i].tagName == 'IMG' || aEls[i].tagName == 'img') { 
       if (aEls[i].src.indexOf(relayurl) == 0 && aEls[i].src.indexOf(relayurl_replace) == -1) { 
        aEls[i].src = aEls[i].src.replace(relayurl, relayurl_replace + "/" + baseurl + "/"); 
       } 
      } 
     } 
    } 

    // 
    // Now start the timer which runs this function again to fix all body elements that might not be loaded in the browser yet 
    // 
    if (startTimer) { 
     setTimeout("replaceRelayButtons(document.body, false)",1000) 
     setTimeout("replaceRelayForms()",1000) 
    } 
} 

// 
// Replace all form actions to NOT use the relay-script when the user clicks on the links 
//        
function replaceRelayForms() { 
    for (i = 0; i < document.forms.length; i++) { 
     if (document.forms[i].action.indexOf(relayurl) == 0) { 
      document.forms[i].action = document.forms[i].action.replace(relayurl_replace, ""); 
      document.forms[i].action = document.forms[i].action.replace(relayurl, "") 
      if (document.forms[i].action.indexOf("http://") != 0) { 
       document.forms[i].action = (baseurl + "/" + document.forms[i].action); 
      } 
     } 
    } 
} 

// 
// Go and replace the urls and form actions 
// 
if (getURLParam('baseurl') != null) { 
    baseurl = getURLParam('baseurl') 
} 
replaceRelayButtons(document.body, true); 

我可能会做错什么?这甚至有可能吗?

回答

0

我认为没有太大的错误,但不能将HTTPS URL加载到HTTP URL中,因为它也应该是安全的URL。这是因为如果URL是另一个域,fancybox会生成一个iFrame。

IE会告诉你一个错误,但Firefox会加载页面,尝试它,你会看到。

更多详细信息:JavaScript HTTPS to HTTP iFrame Security Question

+0

所以基本上它不是可行? – Kristian 2011-12-16 11:55:58

0

我认为的问题。“无法加载所请求的内容,请稍后再试。”它比这个线程https://stackoverflow.com/a/8509018/1055987更关系到你在一个安全的服务器的事实。

所以试着改变你的代码

<div id="inline" style="display:none;width:500px;"> 
    <h2>Always enjoy the sunny days!</h2> 
</div> 

的这部分本

<div style="display:none;"> 
    <h2 id="inline" style="width:500px;">Always enjoy the sunny days!</h2> 
</div>