/    Sign up×
Community /Pin to ProfileBookmark

JS dynamic iframe issue

…I need assistance on iframes..

i have 3 videos, need to click on one and it loads in the iframe.. have that working but can’t get the code so when i click on another it loads it at all

here’s what i have so far

[CODE]<script type=”text/javascript”>
function load(file){
var iframeTag = document.getElementById(‘frame’);
var body = document.getElementsByTagName(‘body’).item(0);
var myiframe = document.getElementById(‘myiframe’);
if(iframeTag) body.removeChild(iframeTag);
iframe = document.createElement(‘iframe’);
iframe.src = file;
iframe.id = ‘frame’;
iframe.width = ‘500px’;
iframe.height = ‘330px’;
iframe.frameborder = ‘0’;
iframe.margin = ‘0’;
iframe.scrolling = ‘no’;
myiframe.appendChild(iframe);
}
</script>

<div id=”myiframe”></div>
<a onclick=”load(‘stuck.php’); return false” class=”ad-wrap”><img src=”../../graphics/clients/jc-stuck.png” alt=”JC” id=”c-ad”/>”Stuck”</a>
[/CODE]

thanks guys

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@ZeroKilledApr 29.2009 — removing element from wrong node. the iframe belong inside a div element, isn't a direct child from the body element.<i>
</i>if(iframeTag) [color=blue]myiframe[/color].removeChild(iframeTag);
Copy linkTweet thisAlerts:
@graphic3authorApr 29.2009 — should that fix my problem? of not being able to load other videos?
Copy linkTweet thisAlerts:
@ZeroKilledApr 29.2009 — it should. according to script when the frame exists in document it is removed, create a new one with the specified document and append to document.
×

Success!

Help @graphic3 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...