Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8534997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:19:36+00:00 2026-06-11T10:19:36+00:00

I have literally read every stackoverflow thread regarding changing the video tag source dynamically

  • 0

I have literally read every stackoverflow thread regarding changing the video tag source dynamically via javascript in IE9, including the useful but not agreed upon posts here and here, but do feel like there is another solution. Here is the very basic example of what I’m trying to do:

    var video = document.getElementById('video');
    //now, use either of the lines of code below to change source dynamically

    video.src = "nameOfVideo";
    //or use...
    video.setAttribute("src", "nameOfVideo");

Both of these lines of code are hated thoroughly by Internet Explorer, notably because the src is most definitely being changeed after being checked with a simple video.getAttribute, even though IE is not actually doing anything to switch the video.

Yes, there are claims that with IE, you MUST have the src’s listed with the HTML in order to change them after the page has loaded, BUT I have definitely found a thread on stackoverflow that proposed a solution via simple JavaScript. (To my disappointment, I can no longer find the thread that did so….and I’ve searched everywhere, believe me).

With all that said, if anyone can provide a solution WITHOUT the use of placing all of the video src’s within the HTML and instead, dynamically setting/creating the src’s using JavaScript as shown above, I would be extremely grateful.

(Or, if you could point me in the direction of the ‘missing’ overflow thread that tests if the attribute exists in IE, and then somehow set the src via javascript, that will also be appreciated).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:19:37+00:00Added an answer on June 11, 2026 at 10:19 am

    Great news, I found a true solution to switching/changing videos in HTML5 video tags via JavaScript without using the annoying hack I tried to explain! It’s unbelievably simple and it just took a LOT of experimenting with IE. Below is the code in its simplest form to work in IE:

    <html>
      <body>
        <video id='videoPlayer' width="320" height="240" controls="controls">
           <source id='mp4Source' src="movie.mp4" type="video/mp4" />
           <source id='oggSource' src="movie.ogg" type="video/ogg" />
        </video>
    
    <!-- You MUST give your sources tags individual ID's for the solution to work. -->
    
        <script>
          var player = document.getElementById('videoPlayer');
    
          var mp4Vid = document.getElementById('mp4Source');
    
          player.pause();
    
          // Now simply set the 'src' property of the mp4Vid variable!!!!
    
          mp4Vid.src = "/pathTo/newVideo.mp4";
    
          player.load();
          player.play();
        </script>
      </body>
    </html>
    

    And there you have it. Unbelievably simple — tested and working in IE8, and IE9…
    If you are having any problems, please let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read all over stack overflow and google about seg faults regarding python
In my career I have seen literally dozens of ways that people choose to
I have a rather large application that has literally a hundred DDLs with Yes
This is literally driving me nuts. I have 2 entities that use NSStrings as
So I have custom UITableViewCells (made with storyboard), and when I do not literally
If I have a file, and I want to literally write '42' to it
Most code I have ever read uses a int for standard error handling (return
I have created a S3 bucket, uploaded a video, created a streaming distribution in
I have some dynamically generated XML data that will be consumed by a few
I have formatted the second script so it could be easily read in notepad

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.