i have the following code
var url = "url";
$('<iframe />', {
name: 'frame',
id: 'frame',
src: url
}).appendTo('body');
but when i click the button, nothing seems to happen
i have the following code
var url = "url";
$('<iframe />', {
name: 'frame',
id: 'frame',
src: url
}).appendTo('body');
but when i click the button, nothing seems to happen
Make sure you put this code in a document.ready:
$(function() {
$('#someButtonId').click(function() {
var url = "url";
$('<iframe />', {
name: 'frame',
id: 'frame',
src: url
}).appendTo('body');
});
return false;
});
The code works correctly as it is right now. The bug is probably elsewhere in the code.
Make sure you don't open the same iframe again and again. Check if it exists!
$('#button').click(function() {
if($('#myIframe').size() == 0) {
$('<iframe id="myIframe" src="http://stackoverflow.com"></iframe>');
}
});
its very simple before click on button clear your div innerhtml where is iframe located
like this document.getElementById("mapdive").innerHTML = "";