0

I have the following Javascript variable.

<script type ="text/javascript">
    document.getElementById("vid").src = video.url();
</script>

How do I put the videoUrl into my movie player.

<video width="320" height="240" controls autoplay>
<embed id="vid" src="videoUrl" width="200" height="200">
</video>
1

1 Answer 1

2

Get the element with javascript (after it is loaded into the DOM) then change its src attribute.

<embed id="vid" src="videoUrl" width="200" height="200">
<script type="text/javascript">
    document.getElementById("vid").src = video.url();
</script>
Sign up to request clarification or add additional context in comments.

5 Comments

Cannot set property of 'src' undefined.
posted the updates. video.url returns a link to a .mp4 file downloaded on a server.
the javascript MUST come after the embed. hence "after it is loaded into the DOM". is that what you did?
However, i do not get the URL until AFTER the javascript is done.
How does that work? Do you set var video = {url : function(){...}} later in your program?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.