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/';
精彩评论