SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Staten Island, NY
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.
    Code JavaScript:
    // 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.
    Code JavaScript:
    <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.
    Code JavaScript:
    <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!

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •