开发者

Using ajax to change iframe

Is it possible to change the URL of an iframe without leaving the page. I.e. Ajax If so how can this be done. Thanks so开发者_如何学编程 much


Yes, using just javascript (I used jQuery)..

Example is here:

http://jsfiddle.net/pYG2z/

HTML:
<iframe id="googframe" src="http://www.google.com"></iframe>
<input type=button id="changeframe" value="Change">


JS:
$('#changeframe').click(function() {
  $('#googframe').attr('src','http://www.msn.com'); 
});


var iframe = document.getElementById('your_iframe');
iframe.src = 'http://example.com/';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜