Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to append xmlns:fb="http://www.facebook.com/2008/fbml" to my CMS's html tag

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?

like image 243
TikaL13 Avatar asked Feb 03 '11 22:02

TikaL13


2 Answers

$(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.

like image 114
lsuarez Avatar answered Nov 08 '22 20:11

lsuarez


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.

like image 41
leat Avatar answered Nov 08 '22 20:11

leat