2013-03-13 185 views

回答

2

我會做到以下幾點:

<div id="linkDiv"> 
    <a href="#" id="theLink">Link</a> 
</div> 
<br/><br/> 
<iframe id="iframe1" name="iframe1" src="#"></iframe> 

$(document).ready(function(){ 
    $("#iframe1").hide(); 
    $("#theLink").click(function(){ 
     $("#iframe1").show(); 
     $("#linkDiv").hide(); 
     return false; 
    }); 
}); 
2

放入span標籤的鏈接並執行以下操作:

$("#link").click(function(e) { 
    e.preventDefault(); 

    //Assuming you're assigning the source dynamically, if not, comment out below line. 
    $("#iframe1").attr("src", $("link").attr("value"); 
    $("#iframe1").show(); 

    $("#linkBeGone").hide(); 
}); 

設置鏈接「#」的href屬性,並將值設置爲希望iFrame的src。

<span id="linkBeGone"><a id="link" value="http://www.example.com/" href="#" target="iframe1">link</a></span> 

</br></br> 

<iframe id="iframe1" name="iframe1" src="#"></iframe>