2011-10-12 24 views
0

我試圖通過鏈接simplemodal來自:Simplemodal在​​

<td><a href="games/BG-1001.php" class ="simple_modal" >EU-ch U12</a></td> 

,並在http://chesstao.com/test-1.php底部我有代碼拿起URL以及加載IFRAME(但它被註釋掉)。

<script src="js/jquery.simplemodal-1.4.1-min.js"></script> 
<script src="js/basic-min.js"></script> 

<script> 
// Display an external page using an iframe 
//var src = "http://365.ericmmartin.com/"; 

$("a").attr("href") 
$('.simple_modal').click(function() { 
var hrefval= $(this).attr("href"); 

}); 


//$.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', { 
//closeHTML:"", containerCss:{backgroundColor:"#fff", borderColor:"#fff", 
//height:450, padding:0, width:830}, overlayClose:true}); </script> 

的問題是,我不能使用一個文字來設置的src: VAR SRC = 「http://365.ericmmartin.com/」; // DW

因爲表格數據中的URL發生變化。

有人可以告訴我如何將評論的代碼與其他代碼混合?我的評估是否正確?

+0

我知道。我一直在嘗試每一個模式和燈箱,我可以找到生產國際象棋gamescores彈出。大多數候選人使用rel =「」,這不會在HTML5中驗證。但我會在勸告下提出您的意見。 – verlager

+0

我會遵從你的建議。 – verlager

+0

我如何表明該解決方案可以接受?我看不到如何... – verlager

回答

0

如何簡單地在點擊事件中調用modal()方法?

$('.simple_modal').click(function(e) { 
    // Get the href value of the <a> that was clicked 
    var hrefval= $(this).attr("href"); 

    // Insert the href value into the parameter of the modal() method 
    $.modal('<iframe src="' + hrefval + '" height="450" width="830" style="border:0">', {closeHTML:"", containerCss:{backgroundColor:"#fff", borderColor:"#fff", height:450, padding:0, width:830}, overlayClose:true}); 

    // preventDefault() stops the default behavior of the <a> that was clicked 
    e.preventDefault(); 
}); 

這裏是一個simplified JSFiddle demo

+0

非常感謝!這工作完美! – verlager

+0

@verlager:很高興爲你效勞! –