Solved

Toggling mode in tich text editor changes relative links to absolute

Posted on 2004-09-08
2
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

733 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