I want to know how I can add these attributes to my html tag that gets auto generated by our closed CMS system.
I would like to add to our current html tag:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
To this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">
Is there any way to do this using JQuery?
$(function () {
$("html").attr("xmlns:og","http://ogp.me/ns#");
}
It's rare that XML namespace attributes in your HTML tag have any relevance on page behavior.
You need to add the namespace declaration to the element, but as I recall you can't use the DOM to add namespace mappings. JQuery uses js-DOM under the covers to manipulate the elements. You should find the code that renders the html element and add it there.
In the past, when I needed to do that in .net / java I had to render the DOM Document Element out to a string and add the xmlns="attr" with a string concatonation, then reparse the string to DOM.
This method will not work in JS though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With