Why does the size of a text input grow when using JS to create a page?

Discussion in 'Javascript' started by Scott Navarre, Feb 16, 2004.

  1. Hello,

    I have noticed that when using JavaScript to create a page, the sizes of
    the text input form elements come out bigger than the size I am trying to
    set them to. I don't know if it matters, but I am using IE6...

    For example: if I create a text input with a size of "1" using straight
    HTML, and then type into it, I can see 2 characters at a time. But when I
    use JavaScript's 'document.write()' function to create the same text input,
    it is noticeably bigger and when I type into it I can see 5 characters at a
    time.
    Here is a short, simple example to illustrate the problem:

    <HTML>
    <HEAD>
    <TITLE>JavaScript Test</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    function createPage()
    {
    var page='';
    page+='<HTML>';
    page+='<TITLE>JavaScript Test</TITLE>';
    page+='<BODY>';
    page+='<FORM>';
    page+='Text Input (Size="1"): <INPUT TYPE="TEXT" SIZE="1">';
    page+='</FORM>';
    page+='</BODY>';
    page+='</HTML>';
    document.write(page);
    document.close();
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <FORM>
    Text Input (Size="1"): <INPUT TYPE="TEXT" SIZE="1">
    <BR><BR><BR>
    <INPUT TYPE="BUTTON" VALUE="Re-render this page using JavaScript"
    onClick="createPage()">
    </FORM>
    </BODY>
    </HTML>

    Am I missing something (doing something wrong)? Or is there anything that
    can be done to fix this problem?

    Thanks in advance,
    Scott Navarre
    Scott Navarre, Feb 16, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guy
    Replies:
    5
    Views:
    2,797
    brucie
    Dec 13, 2003
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    839
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,679
    Smokey Grindel
    Dec 2, 2006
  4. puzzlecracker

    where does system stack grow in cpp?

    puzzlecracker, Oct 6, 2005, in forum: C++
    Replies:
    21
    Views:
    767
    Jack Klein
    Oct 7, 2005
  5. Li Chen
    Replies:
    20
    Views:
    270
    Brian Candler
    Sep 21, 2008
Loading...

Share This Page