Reputation: 5670
I am appending an iframe
to my html through jquery.
Code is like this.
function setImageUrl(imgname) {
$(".large-image iframe").remove();
var u = '<iframe width="560" id="iframevideo" height="315" src="#" frameborder="0" allowfullscreen></iframe>';
$(".large-image").append(u);
document.getElementById('iframevideo').setAttribute("src", imgname);
return true;
}
Parameter imgname is coming correctly and it is the intended Iframe
src
But this always produces a blank iframe
. like this one
On the other hand, If i hardcoded the src
everything works fine.So I assume the issue is some where I am setting src
.I have tried different methodes ,but nothing works.
Upvotes: 0
Views: 252
Reputation: 1548
There is working demo ..
function setimage () {
$("#oldframe").remove();
$("#main").append("iframe tag ");
$('#newframe').attr('src', 'imgurl');
}
Upvotes: 0
Reputation:
Try
document.getElementById('iframevideo').src=imgname;
or
$('#iframevideo').attr('src', imgname);
Upvotes: 1