Help restore data from form fields in Internet Explorer

Discussion in 'Javascript' started by Tim Tyler, Nov 10, 2003.

  1. Tim Tyler

    Tim Tyler Guest

    The user has come back to my page - and I have session data held in
    hidden form fields that I want to restore.

    Getting these values using Javascript works fine in Mozilla Firebird - and
    the like - but there's a problem with Internet Explorer (6).

    IE apparently fills in the form fields the way they were *after*
    the page is loaded.

    Executing Javascript while the page is loading gets the original
    default values - not the ones left stored in the form fields when
    the page was last exited :-|

    I'm sure this must be a common issue - can any kind soul point me
    to the best way to work around the problem?

    Thanks in advance for any assistance!
     
    Tim Tyler, Nov 10, 2003
    #1
    1. Advertisements

  2. Tim Tyler

    Tim Tyler Guest

    <body onLoad="javascript:restore_state_from_form_fields('test');">

    ....is enough, it seems.
     
    Tim Tyler, Nov 10, 2003
    #2
    1. Advertisements

  3. Remove the `javascript:', URIs are wrong here and a label is not needed
    but will cause problems.

    Instead, define the default scripting language in the `head' element:

    <meta http-equiv="Content-Script-Type" content="text/javascript">


    PointedEars
     
    Thomas 'PointedEars' Lahn, Nov 11, 2003
    #3
  4. <snip>

    I have never seen any evidence of the use of superfluous labels in the
    internally generated event handling functions causing problems, unlike
    the use of javascript: URIs in HREF attributes (which certainly do cause
    undesirable side effects). Of course because IE would treat the
    'javascript:' as an indicator of the type of script language to use for
    the attribute code it would be inadvisable to use it as a label in that
    context as the label would be missing form the generated function on IE,
    but its inclusion does seem to be harmless when it is treated as a label
    but never referred to as such.

    I would not recommend prefixing event handling attribute string values
    with 'javascript:' (assuming that JavaScript is the default (and/or
    only) language anyway), but the worst I would say about it is that it is
    an unnecessary 11 bytes of download that servers no practical purpose in
    normal use and may blur the distinction between event handling
    attributes and (the inadvisable use of) javascript: HREFs in the mind of
    the code author.

    Richard.
     
    Richard Cornford, Nov 11, 2003
    #4
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.