Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET HTML HTML5
I want to change SRC and of object tag
it works in firefox but not in Chrome and IE
<script>
 function VideoLoad() {
            var VideoId = $(element).attr('value');
           
            $("#param").attr('value', 'http://www.youtube.com/v/9dLPOpOtKQE?version=3&hl=en_GB');
 
            $("#embed").attr('src', 'http://www.youtube.com/v/9dLPOpOtKQE?version=3&hl=en_GB');
           
           
        }
 
<script>
<pre lang="xml"></pre>
<body>
  <img class="ImgSlide GrayShd"  onclick="VideoLoad()" src="http://img.youtube.com/vi/8Csk8lMfQnA/1.jpg" />
 
  <object width="450" height="420">
                                        <param name="movie" id="param" value="http://www.youtube.com/v/8Csk8lMfQnA?hl=en_GB&amp;version=3">
                                        </param>
                                        <param name="allowFullScreen" value="true"></param>
                                        <param name="allowscriptaccess" value="always"></param>
                                        <embed id="embed" src="http://www.youtube.com/v/8Csk8lMfQnA?hl=en_GB&amp;version=3"
                                            type="application/x-shockwave-flash" width="450" height="420" allowscriptaccess="always"
                                            autostart="true" allowfullscreen="true"></embed></object>
</body>
Posted 2-Apr-13 0:48am
Comments
ryanb31 at 2-Apr-13 7:16am
   
Have you used the developer tools in the browsers where it doesn't work?
Member-515487 at 2-Apr-13 7:20am
   
yes but its was shown any error this code works for Firefox
Sandeep Mewara at 2-Apr-13 10:01am
   
What error?
Member-515487 at 3-Apr-13 2:52am
   
there was no no error in code because src and value getting change i hv check with alert but Object tag not getting refresh it work properly with Mozilla
Member-515487 at 2-Apr-13 7:24am
   
it also work if i use c# method to do but not with script
sri senthil kumar at 3-Apr-13 5:06am
   
Thats because page gets refreshed when you do with c# method. You can do the same with javascript too, try binding whole of object tag instead of the video url alone.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this below code, Hope it helps you.
 
<html>
<head></head>
<body>
 
<div id="player">
 
<object width="640" height="360">
  <param name="movie" value="https://www.youtube.com/v/Zhawgd0REhA?version=3"></param>
  <param name="allowFullScreen" value="true"></param>
  <param name="allowScriptAccess" value="always"></param>
  <embed src="https://www.youtube.com/v/Zhawgd0REhA?version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="360"></embed>
</object>
 
</div>
<a href="#"  önclick="changevideo('oKiYuIsPxYk')"> HTY dargon</a>
<a href="#"  önclick="changevideo('q6uoyPTcfic')"> despicable me 2</a>
 
<script>
function changevideo(id)
{
   
	var divObj = document.getElementById('player');
	divObj.innerHTML = '<object width="640" height="360">'+
		  '<param name="movie" value="https://www.youtube.com/v/'+ id + '?version=3"></param>' +
		  '<param name="allowFullScreen" value="true"></param>'+
		  '<param name="allowScriptAccess" value="always"></param>'+
		  '<embed src="https://www.youtube.com/v/'+id+'?version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="360"></embed>'+
		'</object>';
}
</script>
 
</body>
</html>
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 3 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100