Encoding content into a Hidden Field

Discussion in 'Javascript' started by Plinkerton, Feb 5, 2008.

  1. Plinkerton

    Plinkerton Guest

    Hi folks,

    I want to store some values I get using JavaScript/jQuery into a
    Hidden Field so the Server can read it.

    What are the limits of what I can put in a Hidden Field. Is anything/
    everything ok as long as it gets some kind of HTML Encoding?

    What can't put into a hidden field? Like for example, if I wanted to
    use JavaScript to put a copy of the whole HTML document into a hidden
    field is there any reason I can't do that? I'm curious what the
    limits are.

    Any help is much appreciated.
     
    Plinkerton, Feb 5, 2008
    #1
    1. Advertising

  2. Plinkerton wrote:

    > I want to store some values I get using JavaScript/jQuery into a
    > Hidden Field so the Server can read it.
    >
    > What are the limits of what I can put in a Hidden Field. Is anything/
    > everything ok as long as it gets some kind of HTML Encoding?
    >
    > What can't put into a hidden field? Like for example, if I wanted to
    > use JavaScript to put a copy of the whole HTML document into a hidden
    > field is there any reason I can't do that? I'm curious what the
    > limits are.


    Is a hidden field an <input type="hidden"> element? There are no limits
    when the form is submitted with the POST method. With the GET method
    there have been limits reported for browsers not managing URLs longer
    than 2 KBytes I think but I haven't tested with current browsers.

    And you don't need your script to encode the value you set, the browser
    will do when it submits the form.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 5, 2008
    #2
    1. Advertising

  3. Martin Honnen wrote:
    > [...] With the GET method there have been limits reported for browsers
    > not managing URLs longer than 2 KBytes I think but I haven't tested with
    > current browsers.


    K(ibi)Byte is not an viable unit to measure URI length; although eventually
    converted to ASCII characters by the UA according to RFC3986, an unescaped
    (assigned) URI string may contain characters that require multi-byte
    encoding, such as those from Unicode beyond code point U+0079.

    As for current browsers, according to Microsoft the restriction of maximum
    2083 characters per URI applies to Internet Explorer version 7 as well. I
    don't know whether that applies to the escaped URI or the original unescaped
    one.

    http://support.microsoft.com/?scid=kb;en-us;208427&x=10&y=17

    > And you don't need your script to encode the value you set, the browser
    > will do when it submits the form.


    Exactly.


    PointedEars
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
     
    Thomas 'PointedEars' Lahn, Feb 6, 2008
    #3
    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. Replies:
    1
    Views:
    602
    Kees de Winter
    Feb 25, 2007
  2. Rick
    Replies:
    3
    Views:
    8,598
    Alexey Smirnov
    Apr 13, 2010
  3. GavMc
    Replies:
    4
    Views:
    384
    Evertjan.
    Sep 22, 2005
  4. Roy Adams

    writing from hidden field to text field

    Roy Adams, Dec 20, 2004, in forum: Javascript
    Replies:
    1
    Views:
    224
  5. Roy Adams
    Replies:
    3
    Views:
    293
    Dr John Stockton
    Dec 21, 2004
Loading...

Share This Page