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

J

jluo

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
 
M

Martin Honnen

jluo said:
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.
 
J

jluo

"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?

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
 
D

dave

"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?
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.
 
J

jluo

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.
 
J

jluo

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.
 

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,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top