Dynamic html question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • harry

    Dynamic html question

    Posted this here as it's more (I think?) javascript related than html.

    I have a page that when a user clicks on a button a row is dynamivcally
    added using js to an html table i.e something like -

    var tab = getElement('tab Costs');
    var row = tab.insertRow(t ab.rows.length) ;

    However when I move off this page & click the "back" button the new row is
    not shown.

    The user's shouldn't use the "back" button & I have other measures in place
    to stop resubmitting the pages data etc... but just wondered if this is
    normal behaviour or my fault?

    Only way I can think of to possibly resolve this would be to store the
    entire table in an array & redraw it during the page load() event - am I
    right or am I talking complete rubbish?

    thanks

    harry


  • Martin Honnen

    #2
    Re: Dynamic html question



    harry wrote:
    [color=blue]
    > Posted this here as it's more (I think?) javascript related than html.
    >
    > I have a page that when a user clicks on a button a row is dynamivcally
    > added using js to an html table i.e something like -
    >
    > var tab = getElement('tab Costs');
    > var row = tab.insertRow(t ab.rows.length) ;
    >
    > However when I move off this page & click the "back" button the new row is
    > not shown.
    >
    > The user's shouldn't use the "back" button & I have other measures in place
    > to stop resubmitting the pages data etc... but just wondered if this is
    > normal behaviour or my fault?[/color]

    It probably depends on the browser, Opera 7 for instance is known to
    store a snapshot of the page and go back to that snapshot so with Opera
    7 the row added with script should be visible when the user goes back.
    On the other hand Opera 7 doesn't run any scripts like body onload again
    which causes a headache to some scripters.

    With MSIE I think when the user goes back the content of form controls
    is preserved but otherwise the page is loaded as if requested from the
    server so your dynamically added element are gone.

    --

    Martin Honnen

    Comment

    • Randy Webb

      #3
      Re: Dynamic html question

      harry wrote:
      [color=blue]
      > Posted this here as it's more (I think?) javascript related than html.
      >
      > I have a page that when a user clicks on a button a row is dynamivcally
      > added using js to an html table i.e something like -
      >
      > var tab = getElement('tab Costs');
      > var row = tab.insertRow(t ab.rows.length) ;
      >
      > However when I move off this page & click the "back" button the new row is
      > not shown.[/color]

      Thats because its not in the HTML of the page.
      [color=blue]
      > The user's shouldn't use the "back" button & I have other measures in place
      > to stop resubmitting the pages data etc... but just wondered if this is
      > normal behaviour or my fault?[/color]

      Normal correct behavior.
      [color=blue]
      > Only way I can think of to possibly resolve this would be to store the
      > entire table in an array & redraw it during the page load() event - am I
      > right or am I talking complete rubbish?[/color]

      The solution to that depends on how your navigation is set up.
      If your navigation is via form buttons, you can save the data on the
      server, track a session, and let the server give back what was in the page.


      --
      Randy
      comp.lang.javas cript FAQ - http://jibbering.com/faq

      Comment

      • harry

        #4
        Re: Dynamic html question

        thanks for the replies!

        I am using IE 5.5 (sp2) & am now confident it's not my fault which is what I
        needed clarification of.

        I could go to the expense of saving the entire state of the page & restoring
        if "back" button pressed but it hardly seems worth it. The users are bound
        to point this out as a bug but at least I can counter that now!

        cheers



        "Martin Honnen" <mahotrash@yaho o.de> wrote in message
        news:41812250$0 $22616$9b4e6d93 @newsread4.arco r-online.net...[color=blue]
        >
        >
        > harry wrote:
        >[color=green]
        > > Posted this here as it's more (I think?) javascript related than html.
        > >
        > > I have a page that when a user clicks on a button a row is dynamivcally
        > > added using js to an html table i.e something like -
        > >
        > > var tab = getElement('tab Costs');
        > > var row = tab.insertRow(t ab.rows.length) ;
        > >
        > > However when I move off this page & click the "back" button the new row[/color][/color]
        is[color=blue][color=green]
        > > not shown.
        > >
        > > The user's shouldn't use the "back" button & I have other measures in[/color][/color]
        place[color=blue][color=green]
        > > to stop resubmitting the pages data etc... but just wondered if this is
        > > normal behaviour or my fault?[/color]
        >
        > It probably depends on the browser, Opera 7 for instance is known to
        > store a snapshot of the page and go back to that snapshot so with Opera
        > 7 the row added with script should be visible when the user goes back.
        > On the other hand Opera 7 doesn't run any scripts like body onload again
        > which causes a headache to some scripters.
        >
        > With MSIE I think when the user goes back the content of form controls
        > is preserved but otherwise the page is loaded as if requested from the
        > server so your dynamically added element are gone.
        >
        > --
        >
        > Martin Honnen
        > http://JavaScript.FAQTs.com/[/color]


        Comment

        Working...