Click here to Skip to main content
14,735,978 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hey Guys,
I am working on a bug causing a flickering input box. The page is dynamically created, and I noticed when you start typing in the empty box the text will be flickering as you type and when you delete the content of the box then whatever you type won't be displayed unless you go to different box and click back to the box and you will see the text.

I noticed when the page is created if I set the content to none empty( I tried <!-- -->) then the problem goes away. Basically, the textbox does not like to be empty!!!

Browser Type: IE
The input box is part of a table and the content is filled with the following code:

function enableDesignMode(rte, html, readOnly)
    var frameHtml

    if (fnSetContent.html == null)fnSetContent.html = new Array();
    fnSetContent.html[rte] = [html, readOnly];

    if(html.length == 0 )
        frameHtml = '&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""&gt;';
        frameHtml += "&lt;html id=\"" + rte + "\"&gt;\n";
        frameHtml += "&lt;html&gt;\n&lt;head&gt;\n";

        //to reference your stylesheet, set href property below to your stylesheet path and uncomment
        if (cssFile.length &gt; 0)
            frameHtml += "&lt;link media=\"all\" type=\"text/css\" href=\"" + cssFile + "\" rel=\"stylesheet\"&gt;\n";
            frameHtml += "&lt;style&gt;\n";
            frameHtml += "body {\n";
            frameHtml += "  background: #FFFFFF;\n";
            frameHtml += "  margin: 0px;\n";
            frameHtml += "  padding: 0px;\n";
            frameHtml += "  font-family: Tahoma, Verdana, Arial;\n";
            frameHtml += "  font-size: 80%;\n";
            frameHtml += "}\n";
            frameHtml += "&lt;/style&gt;\n";

        frameHtml += "&lt;/head&gt;\n";
        frameHtml += "&lt;body&gt;\n";
        frameHtml += html + "\n";
        frameHtml += "&lt;/body&gt;\n";
        frameHtml += "&lt;/html&gt;";

        frameHtml = html;

if (document.all)
//      if (fnSetContent.html == null)fnSetContent.html = new Array();
//      fnSetContent.html[rte] = [frameHtml, readOnly];
        if (fnSetContent.html != null)
            fnSetContent.html[rte][0] = frameHtml;
            fnSetContent.html[rte][1] = readOnly;
        var oRTE = frames[rte].document;
        if (frames[rte].ready)
        rteCommand(rte, "fontsize", "2");
        oRTE.onselectionchange = new Function("updateFont('" + rte + "');");
        oRTE.onkeyup = new Function("handleFont('" + rte + "');");
        if(frameHtml.indexOf("STYLE") == -1)
        setTimeout("setEditorStyles('" + rte + "');", 10);

then some other work is done

where the 'html' is the content of the input box...when it is empty the if part get executed which causes the flickering problem!!!

*** I noticed in one of the pages, removing DTD will fix the issue, but then the text box shows undefined.(update)getting undefined was my fault, and not the result of removing DTD, so never mind this...

Removing the url part will fix flickering issue and the text box does not get initialized with undefined
Now, I am wondering what will be consequences if one omits the url field in a doctype tag?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Updated 12-Jun-12 9:19am
Stephen Hewison 6-Jun-12 17:31pm
Can you post a basic example showing this behaviour and explain which browser you are using?
TRK3 6-Jun-12 17:34pm
It might be help if you posted the relevant code.
Stephen Hewison 8-Jun-12 19:16pm
Question? Have you used the developer tools in the browser and set break points throughout your code? My best guess at this point is that one of the events your code is utilising is creating a loop causing the content to be repeatedly applied.
Sergey Alexandrovich Kryukov 11-Jun-12 15:00pm
Please use "Improve question" above and add your new question about doctype; instead of re-posting.

1 solution

So, I ended up removing Doctype tag which fixed ( or masked :) ) the issue...but I think the actual problem was call to validation which probably was somehow in loop, so I will investigate that later and post updates.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900