I have used an iframe which looks like this:
<iframe style='width: 330px; height: 278px' scrolling='no' name="iframeId" class="advPlayer" id="iframeId" frameborder="0" src='../../player/iabpreview.php?adid=<?php echo $selectedAdIdx ?>&autoPlay=true'></iframe>
Whenever I click on a <div>
, I have to change the source of the iframe. I am using the following code:
if ($j.browser.msie) {
frames['iframeId'].window.location="../player/iabpreview.php?adid="+adId+"&autoPlay=true";
}else {
$j(".advPlayer").eq(0).attr("src", "../player/iabpreview.php?adid="+adId+"&autoPlay=true");
}
This works with Firefox, but not with Internet Explorer.
What code would work for Internet Explorer too?
document.getElementById('MsgBoxWindow').getAttribute('src')
works in Internet Explorer, Firefox, Safari, to get the source URL.document.getElementById('MsgBoxWindow').setAttribute('src', urlwithinthedomain)
works on the same browsers to set the source URL.However, the iframe must be loaded before calling. Don't place it before the iframe while calling the JavaScript code. You can place both after the iframe, if you are calling it right after the page load, and it will work as expected.