Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.