problem with innerhtml and IE "view source" - need help please

Discussion in 'Javascript' started by jluo, Sep 10, 2007.

  1. jluo

    jluo Guest

    I found a problem with my application when using "innerhtml" to
    replace the content from the server after making an ajax call. The
    display is perfectly correct, but when I use "view source" on the
    browser, I found the "source" is still the old content the same as
    before I replaced them with the "innerhtml". This causes some problem
    with my other dynamic links based on the content of the page as they
    pull the old content instead of the new content. I wonder if anyone
    knows why and how to resolve it? Any input is appreciated very much.
    Thanks in advance, Jane
     
    jluo, Sep 10, 2007
    #1
    1. Advertising

  2. jluo wrote:
    > I found a problem with my application when using "innerhtml" to
    > replace the content from the server after making an ajax call. The
    > display is perfectly correct, but when I use "view source" on the
    > browser, I found the "source" is still the old content the same as
    > before I replaced them with the "innerhtml".


    "view source" shows you the source code of the document sent to the
    browser, it does not dynamically serialize the current DOM tree.

    > This causes some problem
    > with my other dynamic links based on the content of the page as they
    > pull the old content instead of the new content.


    It is not clear what you are doing. If you use JavaScript then show us
    your code and explain how it relates to the "view source" menu
    functionality of the browser.



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Sep 10, 2007
    #2
    1. Advertising

  3. jluo

    jluo Guest

    On Sep 10, 11:33 am, Martin Honnen <> wrote:
    > jluo wrote:
    > > I found a problem with my application when using "innerhtml" to
    > > replace the content from the server after making an ajax call. The
    > > display is perfectly correct, but when I use "view source" on the
    > > browser, I found the "source" is still the old content the same as
    > > before I replaced them with the "innerhtml".

    >
    > "view source" shows you the source code of the document sent to the
    > browser, it does not dynamically serialize the current DOM tree.


    Thanks for the response. Is there anyway I can replace the source with
    the current DOM tree?


    > > This causes some problem
    > > with my other dynamic links based on the content of the page as they
    > > pull the old content instead of the new content.

    >
    > It is not clear what you are doing. If you use JavaScript then show us
    > your code and explain how it relates to the "view source" menu
    > functionality of the browser.


    It's hard to put the code here as it's way too complicated than it
    sounds.
    Let me see if I can explain it in a simple way:

    Page A -- old content has link url_dynamic been initialized:

    urlArray[x] = Page_B_x.htm;

    <a href=urlArray[x]>New Page</a>

    Page A1 -- new content after using "innerhtml", the same url_dynamic
    within the block that content been replaced, should contain: (at least
    the response text from the server looks like to contain the correct
    content for the urlArray[x])

    urlArray[x] = Page_C_x.htm;

    <a href=urlArray[x]>New Page</a>

    But when I click on the "New Page", the link still goes to the old
    "Page_B_x.htm".

    Any suggestion to this problem?

    Thanks in advance. -Jane
     
    jluo, Sep 10, 2007
    #3
  4. jluo

    dave Guest

    On Sep 10, 10:22 am, jluo <> wrote:
    > On Sep 10, 11:33 am, Martin Honnen <> wrote:
    >
    > > jluo wrote:
    > > > I found a problem with my application when using "innerhtml" to
    > > > replace the content from the server after making an ajax call. The
    > > > display is perfectly correct, but when I use "view source" on the
    > > > browser, I found the "source" is still the old content the same as
    > > > before I replaced them with the "innerhtml".

    >
    > > "view source" shows you the source code of the document sent to the
    > > browser, it does not dynamically serialize the current DOM tree.

    >
    > Thanks for the response. Is there anyway I can replace the source with
    > the current DOM tree?
    >
    > > > This causes some problem
    > > > with my other dynamic links based on the content of the page as they
    > > > pull the old content instead of the new content.

    >
    > > It is not clear what you are doing. If you use JavaScript then show us
    > > your code and explain how it relates to the "view source" menu
    > > functionality of the browser.

    >
    > It's hard to put the code here as it's way too complicated than it
    > sounds.
    > Let me see if I can explain it in a simple way:
    >
    > Page A -- old content has link url_dynamic been initialized:
    >
    > urlArray[x] = Page_B_x.htm;
    >
    > <a href=urlArray[x]>New Page</a>
    >
    > Page A1 -- new content after using "innerhtml", the same url_dynamic
    > within the block that content been replaced, should contain: (at least
    > the response text from the server looks like to contain the correct
    > content for the urlArray[x])
    >
    > urlArray[x] = Page_C_x.htm;
    >
    > <a href=urlArray[x]>New Page</a>
    >
    > But when I click on the "New Page", the link still goes to the old
    > "Page_B_x.htm".
    >
    > Any suggestion to this problem?
    >
    > Thanks in advance. -Jane


    If you use Firefox, you can highlight the text and then view selected
    source. I believe that should work.
     
    dave, Sep 10, 2007
    #4
  5. jluo

    jluo Guest

    Sorry for the confusion. Actually, I don't really care about how the
    source look like. What really bothers me is that my dynamic array did
    not get to set to the value of the new content, even the array
    assignment session is within the "innerhtml" block:

    ~~~~~~~~
    urlArray[x] = Page_B_x.htm;

    <a href=urlArray[x]>New Page</a>
    ~~~~~~~~

    -> it looks like the html that I rendered from the "innerhtml" has the
    correct "urlArray[x] = Page_C_x.htm;" on it:

    ~~~~~~~~ new content in the memory ~~~~~~~
    urlArray[x] = Page_C_x.htm;

    <a href=urlArray[x]>New Page</a>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    But when I click on the "New Page", it did not pick up the correct
    urlArray[x] value which was still staying in the old content of
    "Page_B_x.htm".

    BTW, out application is only running on IE, for the limitation,
    Firefox is not an option.

    Any clue? Thanks in advance.
     
    jluo, Sep 11, 2007
    #5
  6. jluo

    jluo Guest

    Thanks all for the help. I found a solution for it. I guess I had
    expected too much from the simple "innerhtml". Martin and Duncan gave
    me a good hint that this call does not relocate memory for anything.
    It only works for presenting the content on the browser but not
    "storing" it for further use. Just a snap shot of the content. Really
    appreciate for all the inputs! DN, I'll try your way of debugging in
    future if anything is really bad. I'm not a javascript developer, so
    very out in using any native tools. Thanks again for all the help.
     
    jluo, Sep 11, 2007
    #6
    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. Dennis Fazekas
    Replies:
    5
    Views:
    4,910
    =?Utf-8?B?RGVubmlzIEZhemVrYXM=?=
    Jan 1, 2006
  2. KK
    Replies:
    2
    Views:
    592
    Big Brian
    Oct 14, 2003
  3. Jenny
    Replies:
    3
    Views:
    263
    Dag Sunde
    Dec 17, 2004
  4. sonic
    Replies:
    5
    Views:
    291
    Randy Webb
    Jul 11, 2006
  5. dan
    Replies:
    5
    Views:
    207
    David Mark
    Oct 28, 2007
Loading...

Share This Page