views:

477

answers:

1

im working with a cms made a few years ago in asp/vbscript (old asp) and until we release out dot net cms (should be soon) we are stuck with this one but at the moment im trying to make it a bit more w3c compliant ... currently our cms is IE only ... in the page editor

you can switch back and forth from Preview state and html mode and the editor use innerHTML to swap mode but that innerhtml makes all the tags in cap and makes all <LI>...</LI> tags like that <LI>...

no closing tags since it was optional ... i can grab all html tags and attribute keys using regex and swap them to lower case but i was wondering if anyone know an easier way to do so... i tried adding strict mode doctype unfortunately since the code of the editor is really old the whole editor jsut fall apart ...

hopefully we are gonna release our new cms soon but its gonna be a while until we transfer all our sites to the new cms so until then im trying to improve our old code

is there any equivalent to innerHtml that would make the code more w3c Compliant AKA keep the closing tag to my <li></li> so i dont start parsing my ccode using regex and replace ? ty

+1  A: 

If I understand you right, the answer is ‘don't do it’ unless you're going to make any changes to the code in the ‘Preview’ mode.

If that Preview is just plain preview (no WYSIWYG), you should do it like that:

When switching to ‘Preview’ mode, hide the editor (….style.display='hidden' or something like that) leaving the code unmodified inside, and copy it to innerHTML of the preview element.

When switching back, you just discard the code from innerHTML and display editor with old contents again.

Michał Górny
ty for answering unfortunately the problem reside in the fact that users can edit their html in Html mode and once they switch back i gotta feed the preview mode with the new html still a really good answer
Lil'Monkey
If by ‘Html mode’ you mean the mode with editor in it, then there's no problem. You can get the preview element again, and replace it's innerHTML attribute with a new one; i.e. updating it is as simple as: document.getElementById('preview').innerHTML = document.getElementById('editor').value;
Michał Górny