Jump to content

using \n


optikalefx

Recommended Posts

ok this is making me angry

function viewHTML() {
   var html = editDoc.body.innerHTML;
   html = html.replace(/\n/g,"");
   html = html.replace(/>/g,">\n\r");
   var view = editDoc.createTextNode(html);
   //view.style.width = editDoc.body.clientWidth;
   //view.style.height = editDoc.body.clientHeight;
   //view.innerHTML = html;
   editDoc.body.parentNode.replaceChild(view,editDoc.body);
}

 

so the replace functions do work to replace all occurences of a character. BUT id like it not to be a textarea, because im useing document.designMode as well.  so i want it to be in a DIV or something.  So i trie dthis

 

function viewHTML() {
   var html = editDoc.body.innerHTML;
   html = html.replace(/\n/g,"");
   html = html.replace(/>/g,">\n\r");
   var view = editDoc.createElement('DIV');
   view.style.width = editDoc.body.clientWidth;
   view.style.height = editDoc.body.clientHeight;
   view.innerHTML = html;
   editDoc.body.parentNode.replaceChild(view,editDoc.body);
}

 

but that just recreates the body so i escaped it

 

function viewHTML() {
   var html = editDoc.body.innerHTML;
   html = html.replace(/\n/g,"");
   html = html.replace(/>/g,">\n\r");
   var view = editDoc.createElement('DIV');
   view.style.width = editDoc.body.clientWidth;
   view.style.height = editDoc.body.clientHeight;
   view.innerHTML = escape(html);
   editDoc.body.parentNode.replaceChild(view,editDoc.body);
}

 

but that puts a ton of %20s and stuff and doesnt react to the replaces \n's an ahhhhhh

 

i just want

 

Link to comment
https://forums.phpfreaks.com/topic/101813-using-n/#findComment-521928
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.