I’m using the following script to add wmode=”opaque” to embed elements:
jQuery("iframe[src], embed[src]").each(function () {
jQuery(this).prop("src", jQuery(this).prop("src") + "?wmode=opaque");
});
it works fine, but adds the wmode at the last of the embed src like this:
http://www.youtube.com/embed/example?fs=1&feature=oembed?wmode=opaque
And that doesn’t make it work. I want it to be more accurate so it adds wmode as the first attribute after the embed link so no matter how I past the embed url for example :
http://www.youtube.com/embed/example?fs=1&feature=oembed
the script will make it like this:
http://www.youtube.com/embed/example?wmode=opaque?fs=1&feature=oembed
any help?
I think you should compensate for both thins, because
is also wrong, only the first param should have a
?So, you could try:
Just if you like your code to be smaller, you can replace the if statement by:
Also I recommend you take a look at Query string parameters (in the link I left here, or by searching on google)
EDIT
I don’t understand why you need it to be at the beginning, and I’m pretty sure that you just don’t understand how query parameters work.
But, here is the code: