Replace URL in <embed> tag

Asked

Viewed 106 times

1

I have a tag <embed> so in my HTML:

<embed class="flash" src="http://example.com/swf/10/nome.swf">

I wanted to find a way to change the address to http://example.com/swf/5/nome.swf.

Ignoring flashvars, how can I do this in Javascript? I need to use this in Tampermonkey.

1 answer

2


See if it works:

Note: assumes that you have included the Jquery on your page.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>    
<script>
$(document).ready(function() {

      $("embed.flash").each(function() {
        $(this).attr("src", $(this).attr("src").replace("/10/", "/5/"));
      });
    });
</script>

<embed class="flash" src="http://example.com/swf/10/nome.swf">
  • Well, I guess it didn’t work out, but this must be a problem on the site itself, it only activates the swf after running status_toggler(); launch_chatter();. I think that’s why I should look for a way to change this function, but I don’t know if this is the best place to ask. Still, thank you.

  • Oh yes. Also include AJAX on the page.

  • 1

    @Carlos, "ajax"? I think you mean "jquery"...

  • Well remembered, I meant Jquery, already corrected :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.