February 2005 - Posts

HTML - XHTML

When using contentEditable="true" on an object to enable a user to generate ther own HTML IE generates invalid XHTML.

For example :

<IMG src=image.gif border=0>

This should be :

<img src="image.gif" border="0"/>

Note the case, quotes and the closing tag. Even if the HTML used with pasteHTML() is well formed it generates HTML like the first example. I spend the best part of today trying to write a Regular Expression in javascript to convert it with no luck. Until I gaveup and tried to do it with C# and read HTML to XHTML Conversion with SGMLReader article by Peter Bromberg. Its a Helper / Wrapper class for Chris Lovett of Microsoft's SGMLReader.

With this Wrapper you can parse the HTML back to the server and process it to regerate fully valid XHTML. Once you have done this you can use System.XML to manipulate the document just as if it was always XHTML.

 

with 2 Comments

Blog map in the UK too!

I just though I'd add mine too :)

http://www.csthota.com/blogmap/
with 4 Comments

Forcing Garbage Collection on IE

The what?

I blogged a while back about a problem with an IE Memory leak with HTC's. The only solution on the MSDN ( Memory leak occurs when behaviors are dynamically removed ) was to change a setting in the Registry or force the page to reload.

The why?

Bascally the garbage collection was cleaning up th ehtc's until the page had been unloaded. And as far as I know there's know way of forcing IE to start garbage collection on the htc's.

This wasn't going to work as I didn't want to get all the users to fiddle with the registry and reloading the page was against what i was trying to achive which was seamless comunications between the client and the server.

The how?

The other day I thought... iFrames!!!! I could have a iframe object that I load of for heavy work with htc's that can then be unloaded, removed and rerendered.

 // Add Frame Function
function AddFrame(){
   oFrame = NewObj( "iFrame", {}, this, "" );
   oFrameDoc = window.frames[0].document;
   oFrameDoc.open();			
   oFrameDoc.write(GenStdHTML());
   NewObj( "script", {src:'cclgenlib.js'}, oFrameDoc, "", oFrameDoc  )
   oList = NewObj( "ccl:List", {}, oFrame.body, "", oFrameDoc  )
}

Add Frame renders a frame on the page and loads it the html from GenStdHTML. I had to add the script files hare as adding the js file in the GenStdHTML function cause the iframe to disapear! As you can see I am able to add another element to the iFrame (ccl:list) document this is another HTC control that is manulipated in the same way as if it was on the page contain g the iFrame.

 // Generate Base HTML for iFrame
function GenStdHTML(){
   var cHTML     = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
   cHTML        += '<html xmlns:ccl><head><title>CCL Widgets</title>';
   cHTML        += '<LINK href="style.css" type="text/css" rel="stylesheet">';
   cHTML        += '</head>';
   cHTML        += '<body></body></html>';
   return cHTML;
}
 // Remove Frame Function
function RemoveFrame(){		
   oFrameDoc.location = "blank";
   oFrameDoc = null;
   DelObj( oFrame, this );
   oFrame = null;
   AddFrame();
}

I set the location of the iFrame to "blank" so that it unloads and I then delete the iframe from the page.

 // Creates a new Element on screen
function NewObj( tag, a, p, t, d ){
   var o;
   if (!d){ d = document}
   o = d.createElement(tag);
   if (a)for (var att in a) o[att]=a[att];
   if (p) p.appendChild(o);
   if (t) o.appendChild(d.createTextNode(t));
   return o;
}

By doing this the memory usage on the application doesn't continually grow in the same way as it does normally.

Now playing: Pink Floyd - Knocking on Heaven's Door

with 4 Comments

Gmail only letting me give out 10!

After reading Jeffrey Palermo's post about gmail invites I though I'd best pass mine out. So if anyone wants an invite just ask...
with 6 Comments

The DNJ Exodus

It such a shame that so many GREAT blogers are dropping out of DNJ's. Of all the blogs communities i read this is by far the best. 

I guess we can all learn from this, the fact that if you apps don't function well enough people are gonna look else where (I know that it's not .Text fault). 

I'm gonna march on, using Blogjet to post here, and hope that this all gets resolved. 

Sashidhar's Post's a good idea it would be great if all the "Deserters" ;) will cross post as it's a great shame if they were to leave this community. :(  I know I can, and have, updated my RSS reader's feeds it's just... it's just... **SIGH** 

Now playing: Pink Floyd - The Great Gig In the Sky

with 3 Comments