Javascript widget that can generate HTML and be indexed by bots?

I came across a document online for distributing content online via Javascript and to test it out I put together a simple JS file that has instructions to build an HTML link inside a div.

I can call the function remotely from sites hosted on other servers.

This would allow me to change the HTML snippet at any time without having to manually change it on a bunch of sites, I would just need to change it once in the JS file.

This is the JS file.

// JavaScript Document
document.getElementById('thetag').innerHTML+='<a href="http://www.somesite.com" target="_blank" title="My Company Info" class="mstag">Powered By My Company</a>';\\

This is the code snippet to put into other pages.

<script type="text/javascript">(function(){document.write('<div id="thetag"></div>');s=document.createElement('script');s.type="text/javascript";s.src="http://www.somesite.com/js/msawtag.js";setTimeout("document.getElementById('thetag').appendChild(s)",1);})()</script>

this is another variation of it for XML parsed pages.

<script type="text/javascript" language="Javascript" id="wedje_script_yourcompanyname">(function(){c=document.createElement('div');c.id='thetag';s=document.getElementById('thetag');s.parentNode.insertBefore(c,s);w=document.createElement('script');w.type='text/javascript';w.src='http://www.somesite.com/js/msawtag.js';setTimeout("document.getElementById('thetag').appendChild(w)",1);})()</script>

This seems to work fine, however, when I view the output of this script using a Google bot simulator, it does not show the HTML link, which is the whole point of this.

I read on many pages that googlebot can process and index Javascript, including remote JS files, however it doesn’t support all Javascript.

So, is it at all possible to have this script work, but do so in a way where the output can still be indexed by google (and hopefully the other big guys like Yahoo and Bing, but even if it was just google I would be happy).

If that is not possible, I’ll have to go back to using server side languages but I wanted to go the JS route to have a single system that worked on all sites, no matter what language they were coded in.

Any info on this will be greatly appreciated. Thanks!

From what I’ve read, all I know is that Googlebot can open .js files and extract URLs from them (as if they were any old text), but it’s not actually running the javascript. Therefore it is likely that your method will not work based on the Googlebot using the link from the HTML. But it might take it from your javascript file.

Do you have any links that support the idea that the googlebot executes JS?