Tuesday, December 8, 2009

Content query webparts and the HTML Formatting

So this entailed using the CQWP to render an approved article with an image and a 1000 character description.
I created the webpart and its able to pull the image but when it pulls the description it renders the HTML version as opposed to the innerText.
Create "div" tags around the description(value in the XSL) which you can refer to later
so the simple solution is to make the HTML equal to the innerText...

var myText = document.getElementById('div tage name')
myText.innerHTML = myText.innerText

Great it does what was intended and renders the HTML correctly...
BUT..and there is always a BUT..
this works fine in IE but firefox returns an "undefined"...
so back to the drawing board ... :(

so after banging my head ... i decided to check the firefox rendering engine which is GECKO...
now i learn that IE knows about innerText and firefox doesnt know abt it....
go figure this is supposed to be standardised ...
so here's my solution ....


so now i decide ...if the browser returns an undefined then it has to be firefox which i know i have to use "textContent" instead of "innerText"
And PRESTO ..... everybody WINS...

till next time ...