Click here to Skip to main content
13,046,087 members (61,574 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I want to change SRC and of object tag
it works in firefox but not in Chrome and IE
 function VideoLoad() {
            var VideoId = $(element).attr('value');
            $("#param").attr('value', '');
            $("#embed").attr('src', '');
<pre lang="xml"></pre>
  <img class="ImgSlide GrayShd"  onclick="VideoLoad()" src="" />
  <object width="450" height="420">
                                        <param name="movie" id="param" value=";version=3">
                                        <param name="allowFullScreen" value="true"></param>
                                        <param name="allowscriptaccess" value="always"></param>
                                        <embed id="embed" src=";version=3"
                                            type="application/x-shockwave-flash" width="450" height="420" allowscriptaccess="always"
                                            autostart="true" allowfullscreen="true"></embed></object>
Posted 1-Apr-13 23:48pm
ryanb31 2-Apr-13 7:16am
Have you used the developer tools in the browsers where it doesn't work?
Member-515487 2-Apr-13 7:20am
yes but its was shown any error this code works for Firefox
Sandeep Mewara 2-Apr-13 10:01am
What error?
Member-515487 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 2-Apr-13 7:24am
it also work if i use c# method to do but not with script
sri senthil kumar 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
Please Sign up or sign in to vote.

Solution 1

Try this below code, Hope it helps you.

<div id="player">
<object width="640" height="360">
  <param name="movie" value=""></param>
  <param name="allowFullScreen" value="true"></param>
  <param name="allowScriptAccess" value="always"></param>
  <embed src="" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="360"></embed>
<a href="#"  önclick="changevideo('oKiYuIsPxYk')"> HTY dargon</a>
<a href="#"  önclick="changevideo('q6uoyPTcfic')"> despicable me 2</a>
function changevideo(id)
	var divObj = document.getElementById('player');
	divObj.innerHTML = '<object width="640" height="360">'+
		  '<param name="movie" value="'+ id + '?version=3"></param>' +
		  '<param name="allowFullScreen" value="true"></param>'+
		  '<param name="allowScriptAccess" value="always"></param>'+
		  '<embed src="'+id+'?version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="360"></embed>'+

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 3 Apr 2013
Copyright © CodeProject, 1999-2017
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