...

View Full Version : Two embedded WMV on one page ?



Ulysses
01-06-2007, 06:12 AM
Hi,

This is probably quite simple, but it's beyond my simple brain to figure it out, so please be gentle with me. :confused:

We have a page, with regular html content and TWO embedded videos. The code for the videos are as follows:

<script type="text/javascript">function f1154632629343(obj) {obj.parentNode.innerHTML = '<embed src="http://domain.com/zbluescalendar.wmv" width="288" height="259" autostart="1" showcontrols="1" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"> </embed>';}</script><div><img src="http://domain.com/zbluescalendar.jpg" height="216" width="288" alt="" style="cursor:pointer;" onclick="f1154632629343(this)">

<script type="text/javascript">function f1154632629343(obj) {obj.parentNode.innerHTML = '<embed src="http://http://domain.com/zmalaysiancookingcalendar.wmv" width="288" height="259" autostart="1" showcontrols="1" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"> </embed>';}</script><div><img src="http://domain.com/zasiancookingcalendar.jpg" height="216" width="288" alt="" style="cursor:pointer;" onclick="f1154632629343(this)">


The problem is that whereas both thumbnails show on the page, both thumbnails play the same video.

Please help. Thanks.

_Aerospace_Eng_
01-06-2007, 09:27 AM
Yes because both functions have the same name. I believe the function declared last is what is used. You need to pass the url of the video to the function like so.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
function playVid(obj,url)
{
obj.parentNode.innerHTML = '<embed src="'+url+'" width="288" height="259" '
+'autostart="1" showcontrols="1" type="application/x-mplayer2" '
+'pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"> </embed>';
}
</script>
</head>

<body>
<div><img src="http://domain.com/zbluescalendar.jpg" height="216" width="288" alt="" style="cursor:pointer;" onclick="playVid(this,'http://domain.com/zbluescalendar.wmv')">
<div><img src="http://domain.com/zasiancookingcalendar.jpg" height="216" width="288" alt="" style="cursor:pointer;" onClick="playVid(this,'http://domain.com/zmalaysiancookingcalendar.wmv')"></div>
</body>
</html>

Ulysses
01-06-2007, 10:13 AM
Yes because both functions have the same name. I believe the function declared last is what is used. You need to pass the url of the video to the function like so.


Hello _Aerospace_Eng_,

I remember, you came to my rescue before :) Thank you so much. I really appreciate it.

Ulysses
01-07-2007, 05:32 AM
Just one question though.

Is it possible to use/integrate the javascript in the body with the video link rather than in the header?

The reason I ask is because sometimes the videos are different sizes, and this would also allow us to use the same code in a PHP calendar script we have, where it is impractical to edit stuff in the header.

Thanks very much.

_Aerospace_Eng_
01-07-2007, 05:35 AM
It doesn't matter where the script goes as long as its on the page either in between the head tags or the body tags. If you actually tried it else where you would have answered your own question.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<script type="text/javascript">
function playVid(obj,url,wid,hgt)
{
obj.parentNode.innerHTML = '<embed src="'+url+'" width="'+wid+'" height="'+hgt+'" '
+'autostart="1" showcontrols="1" type="application/x-mplayer2" '
+'pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"> </embed>';
}
</script>
<div><img src="http://domain.com/zbluescalendar.jpg" height="216" width="288" alt="" style="cursor:pointer;" onclick="playVid(this,'http://domain.com/zbluescalendar.wmv','288','259')">
<div><img src="http://domain.com/zasiancookingcalendar.jpg" height="216" width="288" alt="" style="cursor:pointer;" onClick="playVid(this,'http://domain.com/zmalaysiancookingcalendar.wmv','288','259')"></div>
</body>
</html>

Ulysses
01-07-2007, 05:54 AM
Thank you very much.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum