Question

Richedit bug with SSL enabled sites

Asked by: ap_sajith

So here is the issue: When I try and access a page with the RichEdit component over SSL, the annoying "This page contains both secure and non secure items" message.

I know that the IFrame without the src attribute is causing the issue. So I tried giving an src attribute to the IFrame, pointing it to "blank.htm". Now the real problem starts. For some reason I get a permission denied error on the d.close() line within the richedit.js file.

Here is the code that I am using:
- RTE.asp
=============================================
<IFRAME ID="edit" CLASS="richEdit" usebr="true"  oneditinit="editInited(this)" STYLE="padding-top: 0px; width: 500; height: 200; border: 0px inset;" TABINDEX="4" src="blank.htm">
    <BODY TOPMARGIN="0" LEFTMARGIN="0" STYLE="color: black; background: white;font: 11px verdana;">
     
    </BODY>
   </IFRAME>
   
   <SCRIPT TYPE="text/javascript">

   function editInited(edit) {
      edit.frameWindow.document.body.style.color = "black";
      //** PASS THE VALUE FROM THE HIDDEN VARIABLE ON REFRESH **
      edit.frameWindow.document.body.innerHTML=window.document.all.txtDescription.value;
   }

   </SCRIPT>
===============================================

- RichEdit.js
===============================================
function initRichEdit(el) {
 if (el.id) { // needs an id to be accessible in the frames collection
  el.frameWindow = document.frames[el.id];
  if (el.value == null)
   el.value = el.innerHTML;
 
  if ( el.value.replace(/\s/g, "") == "" )
   el.value =  "<html>\n" +"<head>\n<title></title>\n</head>\n<body>\n</body>\n</html>";
  var d = el.frameWindow.document;
  d.designMode = "On";
  el.src = "blank.htm";
  d.open();
  d.write(el.value);
  d.close();//==>this is where I get the permission denied error

Thanks in advance for your suggestions. Please let me know if you need to see more of the code.

Cheers!
Sajit

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2005-08-27 at 07:50:49ID21542209
Tags

javascript

Topic

JavaScript

Participating Experts
2
Points
500
Comments
8

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. RichEdit Font
    I need to change the font used by a RichEdit . What's the procedure ? (Basically I need to change only the font size) Also do you have any idea why EM_SETSEL(-1,-1) selects all the text , instead putting the cursor at the end ? ( I use RichEdit 2.0 ) Thanks
  2. RichEdit........
    How can I in a Richedit make colored text, so it looks good. Can I somehow turn off the redrawing in a richedit..??? Here is my little test, but it's very ugly... var Editor: RichEdit; procedure TForm1.editorKeyPress(Sender: TObject; var Key: Char); var i: integer; p,e: ...
  3. RichEdit Font Coordinate ?
    I want to get coordinate of some font in RichEdit by cursor move. For example if cursor is in Line 5 and Index 6 I want to place some other RichEdit object under it, with same position and size. Please help me.
  4. Adding RichEdit to StringGrid !
    Adding RichEdit to StringGrid ! How to add RichEdit component to one cell of StringGrid component ?
  5. Font In Richedit
    How to change font that is sellected or that will be written,not font in whole richedit. Than you.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: ZylochPosted on 2005-08-27 at 08:16:38ID: 14768082

Hi ap_sajith,

I tried this out a few times and haven't found any errors whatsoever. I would recommend using about:blank instead of blank.htm since otherwise the iframe may look a bit weird.

Besides that, I think the most important thing is that your editInited function must go before the iframe code, meaning you have something like:

<script language="javascript" type="text/javascript">
<!--

function editInited(edit) {
   edit.frameWindow.document.body.style.color = "black";
   //** PASS THE VALUE FROM THE HIDDEN VARIABLE ON REFRESH **
   edit.frameWindow.document.body.innerHTML=window.document.all.txtDescription.value;
}

//-->
</script>
<iframe id="edit" class="richEdit" usebr="true" oneditinit="editInited(this)" style="padding-top:0px;width:500px;height:200px;border:0px inset;" tabindex="4" src="about:blank">
   <body topmargin="0" leftmargin="0" style="color:black;background:white;font:11px verdana;">
   </body>
</iframe>

should be fine.

Regards,
Zyloch

 

by: ap_sajithPosted on 2005-08-27 at 08:46:33ID: 14768172

Thanks Zyloch for the prompt response.

The main issue I am trying to solve is to remove the unwanted "This page contains both secure and non secure items" message when browsing the page using an https enabled URL.

The reason why this message is displayed because of the fact that https enabled requests cannot interpret "about:blank" correctly. This is a bug that microsoft acknowledges. When you call an IFrame without an src element, the browser automatically assigns "about:blank" as the source for the frame. The site works perfectly when browsed through an http url.

So, In-order to overcome the issue, I have created a blank.htm file in the root and assigned it as the source for the IFrame. the code is given below
===========================================
                  <SCRIPT TYPE="text/javascript">
                  function editInited(edit) {
                     edit.frameWindow.document.body.style.color = "black";
                     //** PASS THE VALUE FROM THE HIDDEN VARIABLE ON REFRESH **
                     edit.frameWindow.document.body.innerHTML=window.document.all.txtDescription.value;
                  }
                  </SCRIPT>

                  <IFRAME ID="edit" CLASS="richEdit" usebr="true"  oneditinit="editInited(this)" STYLE="padding-top: 0px; width: 500; height: 200; border: 0px inset;" TABINDEX="4" src="blank.htm">
                        <BODY TOPMARGIN="0" LEFTMARGIN="0" STYLE="color: black; background: white;font: 11px verdana;">
                              
                        </BODY>
                  </IFRAME>
======================================================

This removes the secure/un-secure warning. However, the code for the rich text editor does not like this. It throws a permission denied error(the line is specified in the code). The code for the RTE is as follows..

//======================================================
//***** CODE COPYRIGHTED TO Copyright (c) 1999 - 2002 Erik Arvidsson (http://webfx.eae.net/contact.html#erik) ****
// Removing the long copyright spiel for ease of pasting the code here...
//======================================================
 
function initRichEdit(el) {
      if (el.id) {      // needs an id to be accessible in the frames collection
            el.frameWindow = document.frames[el.id];
            if (el.value == null)
                  el.value = el.innerHTML;
            
            if ( el.value.replace(/\s/g, "") == "" )
                  el.value =       "<html>\n" +"<head>\n<title></title>\n</head>\n<body>\n</body>\n</html>";
            var d = el.frameWindow.document;
            d.designMode = "On";
            el.src = "blank.htm";
            d.open();
            d.write(el.value);
            d.close(); //<--This is the line throwing the error
            
            el.supportsXHTML = el.frameWindow.document.documentElement && el.frameWindow.document.childNodes != null;
            
            // set up the expandomethods
            
            // first some basic
            
            el.setHTML = function (sHTML) {
                  el.value = sHTML;
                  initRichEdit(el);
            }
            
            el.getHTML = function () {
                  // notice that IE4 cannot get the document.documentElement so we'll use the body
                  return el.frameWindow.document.body.innerHTML;
                  // for IE5 the following is much better. If you don't want IE4 compatibilty modify this
                  //return el.frameWindow.document.documentElement.outerHTML;
            }

            el.getXHTML = function () {
                  if (!el.supportsXHTML) {
                        alert("Document root node cannot be accessed in IE4.x");
                        return;
                  }
                  else if (typeof window.StringBuilder != "function") {
                        alert("StringBuilder is not defined. Make sure to include stringbuilder.js");
                        return;
                  }
                  
                  
                  var sb = new StringBuilder;

                  // IE5 and IE55 has trouble with the document node

                  var cs = el.frameWindow.document.childNodes;

                  var l = cs.length;

                  for (var i = 0; i < l; i++)

                        _appendNodeXHTML(cs[i], sb);

            

                  return sb.toString();
            };

            el.setText = function (sText) {
                  el.value = sText.replace(/\&/g, "&amp;").replace(/\</g, "&lt;").replace(/\>/g, "&gt;").replace(/\n/g, "<br>");
                  initRichEdit(el);
            }
            
            el.getText = function () {
                  // notice that IE4 cannot get the document.documentElement so we'll use the body
                  // not that it matters when it comes to innerText :-)
                  return el.frameWindow.document.body.innerText;
            }

            // and now some text manipulations
            
            el.execCommand = function (execProp, execVal, bUI) {
                  return execCommand(this, execProp, execVal, bUI);
            }      
            //BOLD
            el.setBold = function () {
                  return this.execCommand("bold");
            }
            //ITALIC
            el.setItalic = function () {
                  return this.execCommand("italic");
            }
            //UNDERLINE
            el.setUnderline = function () {
                  return this.execCommand("underline");
            }
            //SET BACKGROUND COLOR
            el.setBackgroundColor = function(sColor) {
                  return this.execCommand("backcolor", sColor);
            }
            //SET FORECOLOR
            el.setColor = function(sColor) {
                  return this.execCommand("forecolor", sColor);
            }
            //CREATE HYPERLINK
            el.setURL = function() {
                  return this.execCommand("CreateLink");
            }
            //ALIGN LEFT
            el.setAlignLeft = function() {
                  return this.execCommand("JustifyLeft");
            }
            //ALIGN RIGHT
            el.setAlignRight = function() {
                  return this.execCommand("JustifyRight");
            }
            //ALIGN CENTER
            el.setAlignCenter = function() {
                  return this.execCommand("JustifyCenter");
            }
            //ORDERED LIST
            el.setOrderedList = function() {
                  return this.execCommand("insertorderedlist");
            }
            //UNORDERED LIST
            el.setUnOrderedList = function() {
                  return this.execCommand("insertunorderedlist");
            }
            //INDENT
            el.setIndent = function() {
                  return this.execCommand("indent");
            }
            //OUTDENT
            el.setOutdent = function() {
                  return this.execCommand("outdent");
            }
            //SETS THE FORE COLOR
            el.SetForeColor = function() {
                  var arr = showModalDialog("RTE/Palette.htm", "", "font-family:Verdana; font-size:9; dialogWidth:185px; dialogHeight:210px; scroll:no; status:no; unadorned:no");

                  if (arr != null) return this.execCommand("forecolor", arr);                  
            }      
            //INSERTS PARAGRAPH            
            el.setParagraph = function() {
                  return this.execCommand("InsertParagraph");
            }
            el.surroundSelection = function(sBefore, sAfter) {
                  var r = this.getRange();
                  if (r != null)
                        r.pasteHTML(sBefore + r.htmlText + sAfter);
            };
            el.getRange = function () {
                  var doc = this.frameWindow.document;
                  var r = doc.selection.createRange();
                  if (doc.body.contains(r.parentElement()))
                        return r;
                  // can happen in IE55+
                  return null;
            };

            /* modifies the enter keyup event to generate BRs. */

            /* Enabled by default */
            
            if (el.getAttribute("usebr")) {
            
                  el.frameWindow.document.onkeydown = function () {
                        
                        if (el.frameWindow.event.keyCode == 9) {

                              document.FrmTask.selStatus.focus();
                              return false;

                        }

                        if (el.frameWindow.event.keyCode == 13) {      // ENTER
                              var sel = el.frameWindow.document.selection;
                              if (sel.type == "Control")
                                    return;
                              
                              var r = sel.createRange();      
                              r.pasteHTML("<BR>");
                              el.frameWindow.event.cancelBubble = true;
                              el.frameWindow.event.returnValue = false;

                              r.select();
                              r.moveEnd("character", 1);
                              r.moveStart("character", 1);
                              r.collapse(false);
                              
                              return false;
                        }
                  };
                  el.frameWindow.document.onkeypress =
                  el.frameWindow.document.onkeyup = function () {
                        if (el.frameWindow.event.keyCode == 13) {      // ENTER
                              el.frameWindow.event.cancelBubble = true;
                              el.frameWindow.event.returnValue = false;
                              return false;
                        }
                  };                  
            }
            
            // Add your own or use the execCommand method.
            // See msdn.microsoft.com for commands

            // call oneditinit if defined
            if (typeof el.oneditinit == "string")
                  el.oneditinit = new Function(el.oneditinit);
            if (typeof el.oneditinit == "function")
                  el.oneditinit();
      }
      
      function execCommand(el, execProp, execVal, bUI) {
            var doc = el.frameWindow.document;
            var type = doc.selection.type;
            var oTarget = type == "None" ? doc : doc.selection.createRange();
            var r = oTarget.execCommand(execProp, bUI, execVal);
            if (type == "Text")
                  oTarget.select();
            return r;
      }
}

function initAllRichEdits() {
      var iframes = document.all.tags("IFRAME");
      
      for (var i=0; i<iframes.length; i++) {
            if (iframes[i].className == "richEdit")
                  initRichEdit(iframes[i]);
      }
}

if (window.attachEvent)      // IE5
      window.attachEvent("onload", initAllRichEdits)
else if (document.all)      // IE4
      window.onload = initAllRichEdits;
======================================================

Hope you understand the full extend of my problems :) BTW... I really dont think that placing of the function above or below the IFrame code is an issue since it is a Javascript function (Would have thrown an error if it cannot locate the function).

Cheers!
Sajit

 

by: ZylochPosted on 2005-08-27 at 08:53:41ID: 14768191

Egads! I've never really worked with SSL so I didn't know about the about:blank bug (pfft, Microsoft...) Thanks :-)

As for the Javascript function ordering, I thought the same, until I had mine after the iframe. IE kept complaining that oneditinit wasn't a proper property and stuff so... just thought I'd mention it.

The richedit.js I used was http://www.webfx.nu/dhtml/richedit/js/richedit.js and it gives me no errors with the blank.html page. I copied the one you used and I started getting errors. Let me look at this more in depth.

Regards...

 

by: ZylochPosted on 2005-08-27 at 08:55:16ID: 14768196

Ah, wait, I see why. Let me think on this a bit.

Regards...

 

by: ZylochPosted on 2005-08-27 at 10:39:30ID: 14768473

I've been playing with this for a few hours now and still no-go. The documentation on designMode is sketchy at best and Javascript behaves quite weirdly when designMode is turned on for the iframe (it behaves strangely when you do something like d.designMode = "Off" too...)

I really have no idea how to disable the SSL warning with RichEdit. The only alternatives I can think of is to use something like HTMLArea instead. If anyone else has gotten this to work, please post.

Regards...

 

by: ap_sajithPosted on 2005-08-28 at 09:45:36ID: 14771703

Thank you zyloch for your comments.

I am really desperate to get this working at the earliest. Any help would be welcome :)

Arent there any other knights in shining armour who could save me on this one :))

Cheers!!

 

by: JunkManPosted on 2005-09-01 at 09:28:23ID: 14803639

ummm, have you tried other editors? FCKEditor is open source, works with firefox, and it's FREE.... altough i'm not sure if it works with SSL, but give it a try...

 

by: ap_sajithPosted on 2005-09-13 at 21:35:24ID: 14878219

I couldnt resolve this issue... But this prompted me to look at other opportunities and I ended up buying a redistributable licence for an RTE from Cutesoft.net. It is a really powerful RTE, easily configurable and easily maintanable.

Thank you both for spending time answering the question. I am splitting the points between the two of you.

Cheers!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...