0

Sorry if this is a really simple question but I'm new to web design and don't know where to turn.

Say I have a page with an embedded object, like a youtube video or something. I want to be able to change that object, say to a different video, when I click a button somewhere on the page. What is the easiest/best solution for accomplishing this?

I currently have two nearly identical pages but with different videos and a button that links to the other page. I thought this was a stupid way of doing things and was wondering if anyone can give me a better way of doing this.

  • [This thread](http://stackoverflow.com/questions/2554149/html-javascript-change-div-content) shows how to do it. :) You can add their code into a button click event. – BrettFromLA Jan 31 '14 at 00:39
  • Sorry, I'm still very new at this so I'm not sure I follow. I made a button, added an onClick event on it to run a script with the "document.getElementById("content").innerHTML = "whatever";" line, but I'm not sure where or how to define the new object (embedded video, for example). – user3255461 Jan 31 '14 at 01:14
  • Okay I figured out most of it. Now it's a problem with my embedded object. I can't seem to figure out how Flickr's embedded slideshow works with iframe and anything else really. – user3255461 Jan 31 '14 at 01:35
  • Sorry, I don't have any experience with Flickr's embedded slideshow object. I just figured you could replace the text "whatever" with the HTML of the object, and it would work like magic. That's usually what happens! – BrettFromLA Jan 31 '14 at 18:29
  • What does .innerHTML actually return? I actually used the line "document.getElementById("content").src="whatever";" to get it to change the src of an iframe and that worked. Flickr embedded slideshows are an object and I think some value inside the param actually tells it where to look for the photos. I tried to give the param an id and change the value with "document.getElementById("content").value="whatever";" but that doesn't seem to work. Any idea on what I have to do to change the value inside a param? – user3255461 Feb 01 '14 at 04:44

0 Answers0