Can I Embed Javascript As An Xhtml Attribute?
I want to update this code to call javascript in order to validate the url of my image. This is PHP echoing xhtml with embedded javascript. echo '
Solution 1:
No, that is invalid XHTML. You end up setting the src to <script type=
and then you have invalid markup.
You should do something like:
echo "<imgid=\"theimg\" class = \"c\" src=\"$fav\" alt=\"\"\/><aname = \"a1\" class = \"b\" href = \"$ass_array[url]\">$ass_array[name]</a>";
?>
<scripttype="text/javascript">document.getElementById('theimg').setAttribute('src', validate_fave($fav));
</script><?php
Post a Comment for "Can I Embed Javascript As An Xhtml Attribute?"