Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading videos inside a div

Status
Not open for further replies.

jamiecottonuk

Technical User
Oct 29, 2007
12
GB
Hi all,

I have found some code that uses javascript to change the image in a div without reloading the page

I have made a quick test page here http://www.mikecotton.com/test/

HTML Code
Code:
<div id="previewPane">
	<img src="sub1_large.jpg"/>
</div>
<div id="theImages">
	<a href="" onclick="showPreview('sub1_large.jpg');return false"><img src="sub1_thumbnail.jpg"/></a>	
	<a href="" onclick="showPreview('sub2_large.jpg');return false"><img src="sub2_thumbnail.jpg"/></a>			
	<a href="" onclick="showPreview('sub3_large.jpg');return false"><img src="sub3_thumbnail.jpg"/></a>	
</div>

Javascript code
Code:
function showPreview(imagePath)
{
	var subImages = document.getElementById('previewPane').getElementsByTagName('IMG');
	if(subImages.length==0){
		document.getElementById('previewPane').appendChild(img);
	}
	else img = subImages[0];
	img.src = imagePath;
}

My question is how would I do the same thing if I wanted it to work with videos instead of images.
For example the user clicks a thumbnail and the video would be displayed in the preview pane instead of another image?
 
It really depends on the technology you are using to display videos. If you're using Flash, I'd go for the Flash integration kit (which gives you a proxy to talk between JS & Flash).

If you're using standard embed / object elements (so WMP, Quicktime, etc), you should be able to target them using their ID (as you have with images), and set the relevant param (usually "src", from memory).

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top