Link to home
Start Free TrialLog in
Avatar of unmeshm
unmeshm

asked on

innerHTML set using Javascript is not visible on View Page Source

I am generating dynamic pages on my site using innerHTML (see example below).
<html>
<head>

<script type="text/javascript">

function load() {
      document.getElementById("content").innerHTML="New Content";
}

</script>

</head>
<body onload="load();">
<div id="content">Old content</div>
</body>
</html>

When I do a "View-Page Source" on the browser (both IE and Firefox), I was expecting to see:
<div id="content">New Content</div>
but instead I see:
<div id="content">Old Content</div>

The Page on the browser, though, display "New Content" correctly. Only the View-PageSource is the problem. Any idea on how to do this so that the "View-PageSource" shows the changed content?

The reason, I ask is because I am expecting Search Engine bots to visit the dynamic pages and if the content that gets displayed to the bots is not the "new content" then my dynamic pages are useless.

Any other way of doing this would also be appreciated.
SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of unmeshm
unmeshm

ASKER

Thanks folks. I guess I will have to rewrite to have the content be generated on the Service side instead of using Javascript. Its an AJAX site hence the heavy reliance on innerHTML. But if the bots are not going to see the dynamic content - javascript is out. Will wait for a few more hours before disbursing the points.
Avatar of unmeshm

ASKER

mplungian: here is an example URL from my site: http://www.sadakmap.com/p/Cafe-Coffee-Day/

As you can see, when this URL is opened, other neighborhood places show up on the sidebar and they have embedded links in them that I wanted the bot to visit and index. I am filling up the sidebar using Javascript (setting innerHTML). I will look into setting this on the server side.
Ahh.

Yes if you do not want to gamble that google follows ajax data, you can put the links in a nice table in a <noscript></noscript> tag

I seem to have read something about the danger of sniffing the bot and serve google prechewed pages...