0

May sound like a total noob question but i'm looking for a javascript (and or jquery) function to replace an element in this code :

<embed id="ply" width="800" height="400" 
 flashvars="file=http://example.com/play/"
 allowscriptaccess="always" 
 allowfullscreen="true" 
 quality="high" bgcolor="#00000" 
 name="ply" style="" 
 src="/video-player.swf" 
 type="application/x-shockwave-flash"/>

I want to be able to replace the :

flashvars="file=http://example.com/play/"

and append some text (for video seeking) :

flashvars="file=http://example.com/play/234983"

Must be really easy to do, but i'd appreciate help for some more experienced user.

5
  • Do you realize changing the attribute string will not automatically reload the video with your new url? Commented Nov 25, 2009 at 19:12
  • Mmmh you're right, how can I force the player to reload ? Commented Nov 25, 2009 at 19:20
  • you could modify it as I gave an example below, but remove and then reappend it. Commented Nov 25, 2009 at 19:21
  • Not sure to understand, can you give an example ? Commented Nov 25, 2009 at 19:29
  • i expanded my original answer. hopefully that will clarify what i mean. Commented Nov 25, 2009 at 20:08

1 Answer 1

1
$("#ply").attr("flashvars", $("#ply").attr("flashvars") + "/234983");

Update If you want to reload the player, this may work. It will clone the existing embed tag with the ID ply, only replacing the flashvars attribute value. This effectively removes ply from the DOM and then inserts it in place again. This would hopefully cause the browser to reload the player.

var p = $("#ply");
p.replaceWith(p.clone().attr("flashvars", p.attr("flashvars") + "/234983"));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.