2010-09-17 32 views
0

我使用下面的示例在我的網站上的iframe中顯示網站。我使用下面的代碼:在iframe對話框中加載網站,jquery

$(document).ready(function() { 
$('a#verd').click(function(e) { 
    e.preventDefault(); 
    var $this = $(this); 
    var horizontalPadding = 30; 
    var verticalPadding = 30; 
    $('<iframe id="externalSite" class="externalSite" src="' + this.href + '" />').dialog({ 
     title: ($this.attr('title')) ? $this.attr('title') : 'External Site', 
     autoOpen: true, 
     width: 800, 
     height: 500, 
     modal: true, 
     resizable: true, 
     autoResize: true, 
     overlay: { 
      opacity: 0.5, 
      background: "black" 
     } 
    }).width(800 - horizontalPadding).height(500 - verticalPadding);    
}); 
.... 
}); 

....這是完全一樣的代碼作爲例子,但它並沒有爲我工作。然而,點擊事件是觸發的,我測試了它的警報。任何想法什麼是錯的?

編輯:

我的網站結構

<html><head> 

<script type="text/javascript" src="/js/jquery/jquery-1.4.2.min.js"></script> 
<script type="text/javascript" src="/js/frontend.js"></script> 
<script type="text/javascript" src="/js/jquery.corner.js"></script> 

<script type="text/javascript"> 
//<!-- 
$(document).ready(function() { 
    $('a#beginning').click(function() { $.post('/programme/list/page/1', {"format":"json"}, function(data, textStatus) { displayProgramms(data); }, 'html');return false; }); 
    $('a#end').click(function() { $.post('/programme/list/page/11', {"format":"json"}, function(data, textStatus) { displayProgramms(data); }, 'html');return false; }); 
}); 
//--> 

</script></head> 
<body> 
<div id="container"> 
<div id="header"> 
<div id="logo"> 
</div> 
</div> 
<div id="navholder"> 
... 
</div> 
<div id="contentwrapper" class="frontpage"> 
.... 
</div> 
<div id="sidewrapper"> 
... 
</div> 
<div id="footerwrapper"> 
... 
</div> 
<div id="disclaimer"> 
... 
</div> 
</div> 

</body></html> 

JS代碼位於frontend.js

+0

你能顯示html嗎? – marcgg 2010-09-17 15:44:50

+0

我添加了我的html – 2010-09-17 16:04:33

+0

你有工作嗎? – mcgrailm 2010-09-17 18:10:07

回答

0

工作正常,我。確保你的html中有一個「verd」的鏈接,並且確保你已經加載了jquery ui

編輯

從你的HTML看起來像你缺少jquery ui

+0

你用ui表示什麼? oO沒有任何jQuery UI加載 – 2010-09-17 16:05:07

+0

0

試試這個:

$('a#verd').click(function(e) { 

    e.stopPropagation(); 

    var self = $(this), 
     horizontalPadding = 30, 
     verticalPadding = 30, 
     dtitle = $(this).attr('title')) ? $(this).attr('title') : 'External Site'; 

    $('<iframe id="externalSite" class="externalSite" src="' + this.href + '" />').dialog(
     { 
     title: dtitle, 
     autoOpen: true, 
     width: 800, 
     height: 500, 
     modal: true, 
     resizable: true, 
     autoResize: true, 
     overlay: { 
      opacity: 0.5, 
      background: "black" 
     } 
     } 
    ).width(800 - horizontalPadding).height(500 - verticalPadding);    

    return false; 
}); 

??? 你打電話給jquery ui嗎?