2012-01-28 60 views
0

我一直在試圖添加最新的ColorBox jquery插件到我正在構建的網站,並且每次我嘗試在ifrae彈出窗口中加載url時,我都會得到在iframe中顯示下列消息(框架本身完美地生成 - 它只是不能SEM在內容拉):ColorBox iframe - 在服務器上找不到要求的url/undefined

>Not Found 
> 
>The requested URL /myfolder/undefined was not found on this server. 

我曾與當地發現鏈接(例如info_page.php)和外部鏈接(試過這種例如http://www.google.com)。我無法弄清楚它爲什麼不加載,因爲我的代碼幾乎直接從colorBox示例中解除。

我的HTML(在頭)是:

<!--COLORBOX--> 

    <link rel="stylesheet" href="css/colorbox.css" /> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> 
    <script src="javascript/jquery.colorbox.js"></script> 
    <script> 
     $(document).ready(function(){ 
      //Examples of how to assign the ColorBox event to elements 
      $(".group1").colorbox({rel:'group1'}); 
      $(".group2").colorbox({rel:'group2', transition:"fade"}); 
      $(".group3").colorbox({rel:'group3', transition:"none", width:"75%",  height:"75%"}); 
      $(".group4").colorbox({rel:'group4', slideshow:true}); 
      $(".ajax").colorbox(); 
      $(".youtube").colorbox({iframe:true, innerWidth:425, innerHeight:344}); 
      $(".iframe").colorbox({iframe:true, 'href' : $(this).attr('href'), width:"80%", height:"80%"}); 
      $(".inline").colorbox({inline:true, width:"50%"}); 
      $(".callbacks").colorbox({ 
       onOpen:function(){ alert('onOpen: colorbox is about to open'); }, 
       onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); }, 
       onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); }, 
       onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); }, 
       onClosed:function(){ alert('onClosed: colorbox has completely closed'); } 
      }); 

      //Example of preserving a JavaScript event for inline calls. 
      $("#click").click(function(){ 
       $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here."); 
       return false; 
      }); 
     }); 
    </script> 

    <!--END COLORBOX--> 

,我用它來生成這個身體鏈接:

<a class="iframe" href="http://google.com/">Test</a> 

JavaScript文件和CSS文件,我還沒有從改變在colorBox網站上找到。任何幫助將不勝感激 - 如果需要更多的信息讓我知道。

(注:我目前在本地運行的網站)
http://jacklmoore.com/colorbox/

回答

0

是什麼瀏覽器您使用?

ColorBox使用ajax動態加載內容,許多瀏覽器阻止該操作作爲安全策略的實現。本地開發有時會無意中導致被禁止的情況。

需要考慮的事情:

你看到所有的瀏覽器這種行爲? 您可以在真正的遠程服務器上安裝項目嗎?

PS。對不起,這不是真正的SO意義上的「答案」...

+0

嗨凱文M,謝謝你的回答。 我正在使用最新的Chrome瀏覽器並在Firefox上進行了測試 - 兩者都是同一個問題。我現在沒有可以上傳的網絡主機,但在本地進行的其他Ajax調用似乎也可以工作。 這很奇怪 - 我只是無法弄清楚。 – 2012-01-28 23:30:07

+0

嘿喬希,你的代碼在Chrome 16.0.912.blah blah和FFox 7.0.1上完全適合我,在以下情況下:(a)指向本地文件的href,(b)使用完整格式指向外部鏈接的href(「 === http:// www.bing.com ===「)。它可以這麼簡單嗎?請注意,我只用了語句$(「。iframe」)。colorbox ...在我的測試中,所以也許在演示代碼的其他地方有衝突。 (如果你不需要它,請將它註釋掉......) – 2012-01-30 20:34:52

+0

對上面引用的Bing的URL感到抱歉;我無法擊敗SO的自動格式化。重點是將您的URL引用更改爲更完整的格式。 – 2012-01-30 20:36:36

相關問題