Reputation: 2094
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
Upvotes: 2
Views: 7339
Reputation: 38516
Yes, using just javascript (I used jQuery)..
Example is here:
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');
});
Upvotes: 2
Reputation: 180004
var iframe = document.getElementById('your_iframe');
iframe.src = 'http://example.com/';
Upvotes: 2