Solved

Toggling mode in tich text editor changes relative links to absolute

Posted on 2004-09-08
2
326 Views
Last Modified: 2008-01-09
Hello.

I am using a simple rich text editor that I like very much.  But it is doing something wierd with the links!  When I add a link, relative link, everything works fine.  When I views the source using toggleHTMLSrc(rte) the link shows up as relative.  But when I click to go back into editing mode, again calling toggleHTMLSrc(rte), the link is turned into an absolute link!  This is messing things up because the editor is in the admin directory.

Any idea what is going on here?

Thanks!


-----------------------------
function toggleHTMLSrc(rte) {
      var oRTE;
      if (document.all) {
            oRTE = frames[rte].document;
      } else {
            oRTE = document.getElementById(rte).contentWindow.document;
      }
      
      if (document.getElementById("chkSrc" + rte).checked) {
            document.getElementById("Buttons1_" + rte).style.visibility = "hidden";
            document.getElementById("Buttons2_" + rte).style.visibility = "hidden";
            document.getElementById("Buttons3_" + rte).style.visibility = "hidden";
            if (document.all) {
                  oRTE.body.innerText = oRTE.body.innerHTML;
            } else {
                  var htmlSrc = oRTE.createTextNode(oRTE.body.innerHTML);
                  oRTE.body.innerHTML = "";
                  oRTE.body.appendChild(htmlSrc);
            }
      } else {
            document.getElementById("Buttons1_" + rte).style.visibility = "visible";
            document.getElementById("Buttons2_" + rte).style.visibility = "visible";
            document.getElementById("Buttons3_" + rte).style.visibility = "visible";
            if (document.all) {
                  //fix for IE
                  var output = escape(oRTE.body.innerText);
                  output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E");
                  output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E");
                  
                  oRTE.body.innerHTML = unescape(output);
            } else {
                  var htmlSrc = oRTE.body.ownerDocument.createRange();
                  htmlSrc.selectNodeContents(oRTE.body);
                  oRTE.body.innerHTML = htmlSrc.toString();
            }
      }
}
-------------------
0
Comment
Question by:hankknight
2 Comments
 
LVL 1

Accepted Solution

by:
Webby_ earned 500 total points
ID: 12009997
I don't have a javascript solution for this one, but in my time as webdeveloper i've encountered the same problem.
We always used a simple workaround. You say admin, so i guess the data gets posted and parsed in a serverside language. Simply replace the "/admin" for "" before you put the data into the database..
0
 
LVL 16

Author Comment

by:hankknight
ID: 12010156
I thought I was going crazy (and the only person to ever run into this)

Glad to hear I'm not loosing my mind . . .
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now