Help restore data from form fields in Internet Explorer

T

Tim Tyler

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!
 
T

Tim Tyler

I said:
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?

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

....is enough, it seems.
 
T

Thomas 'PointedEars' Lahn

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

....is enough, it seems.

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
 
R

Richard Cornford

Thomas 'PointedEars' Lahn said:
Remove the `javascript:', URIs are wrong here and a label is
not needed but will cause problems.
<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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top