Reputation: 1087
I have here an embed code from youtube and Im using a plugin to show that video
<object width="350" height="200">
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://www.youtube.com/v/KVu3gS7iJu4&autoplay=0&loop=0&rel=0" />
<param name="wmode" value="transparent">
<embed src="http://www.youtube.com/v/KVu3gS7iJu4&autoplay=0&loop=0&rel=0" type="application/x-shockwave-flash" wmode="transparent" allowfullscreen="true" allowscriptaccess="always" width="350" height="200">
</embed>
</object>
My problem is I cannot edit those codes, I need to change the "&" sign to "&
" for w3c validation, is this possible using jquery
here is My sample fiddle which is not working and dont know how http://jsfiddle.net/kfX9M/
Upvotes: 1
Views: 343
Reputation: 2928
Hi dude i did with jQuery and Regular Expressions.,
<script type="text/javascript">
$(document).ready( function() {
var re=/&/g;
var value=$("param[name='movie']").val();
var modified_value=value.replace(re,'&');
$("param[name='movie']").val(modified_value);
var src = $("embed").attr('src');
var src_modified_value=src.replace(re,'&');
$("embed").attr('src',src_modified_value);
});
</script>
i think this may help you to resolve your problem.
To see it in action : http://jsfiddle.net/john_rock/7H2Hk/
Upvotes: 0
Reputation: 324650
Changing it with jQuery won't make your HTML valid. You could change it server-side with some PHP:
$dom = new DOMDocument();
$dom->loadHTML($your_embed_code_here);
$xpath = new DOMXPath($dom);
$items = $xpath->query("//*[contains(@href,'&')]");
$l = $item->length;
for($i=0; $i<$l; $i++) {
$items->item($i)->setAttribute("href",str_replace("&","&",$items->item($i)->getAttribute("href")));
}
$out = $dom->saveHTML();
But, as mentioned by elclanrs, it really makes no difference.
Upvotes: 2