Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

The smoke and mirrors of Javascript links

         

wickedthoughtz

6:54 pm on Jun 28, 2005 (gmt 0)

10+ Year Member



I'm in the process of redoing my entire website, and wanted to make a menu bar that is going to appear on every page of my website. I was planning on using javascript "rollover" images from within dreamweaver. i have read many posts stating google can't follow these types of links, but most of the discussions I have read on this topic are now years old. So I was hoping to reinvigorate this topic, with any new knowledge about how skilled google (and other engines) have become at following javascript links. This would, aesthetically, help my site appreciably, but all of my subpages have important keywords that help generate traffic for me, so losing any PR associated with these subpages would kill me. Any help and information is highly appreciated. thanks.

Dijkgraaf

3:07 am on Jun 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is one version of Googlebot with the user agent of "Mozilla/5.0 (compatible; Googlebot/2.1; ..)" that appears to try and find URL's in JavaScript (or rather just isn't ignoring JavaScript).
I've seen it try and request a page based on a string that was is only in JavaScript within a page.
The string was in the form of 'example1.example2.co' however it did a GET /example1.example2.co from my domain, I can't tell you if it also tried a GET / on the example1.example2.co domain however.
It even recently started to request external JavaScript files.

tedster

4:53 am on Jun 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Javascript image rollover functions absolutely do not need to affect the spiderability or indexability of your pages. As long as the link itself is a straighforward <a href="page.html" onmouseover="some-action" onmouseout="someaction"><image stuff here></a> you are fine.

Trouble comes when the target url is generated via javascript and not available within the vanilla html portions. And if you think about it, there's no reason for a javascript rollover to get anywhere near the url of the link - it's only swapping images, after all.

However, for your end users, I still feel it's better to generate "rollover" behavior with CSS hover rules. You can swap out background images and still use actual text for the link. This also keeps your html code much leaner.

BigDave

5:10 am on Jun 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If it is recognisable as an absolute URL, and is anywhere in the page, including text areas, googlebot can and will follow that link.

Google will not give you credit for that link when it comes to PR, nor will you get any credit for anchor text if it is not a straight forward <a href link.

If you are going to be playing with JS links, make sure you test your code in all browsers.

Spine

5:28 am on Jun 29, 2005 (gmt 0)

10+ Year Member



I have a post pending, one part of which is dealing with javascript links.

I'm looking at a site for somebody, and there seem to be multiple issues causing spidering of the site to suffer.

On each product category page, they have links like this

<a onclick="openEnlarged(1026)" href="#">

that create a popup window with the individual product info.

I don't use javascript if I can help it, so I'm not sure, but that's not 'the good kind' of javascript link is it?

They also have a nav menu that relies on an external file, I don't think it's working too well for the bots either.

stever

6:42 am on Jun 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



# or "javascript:;" are also known as null links - in other words, they are creating an "event" or "fake" link for the Javascript to react to. So I would guess that in this case the URL to open is embedded in the script and, in answer to your question, these are not "good" links.

A better way to create the same effect (if you wanted the information spidered) would be to open the real target in a new window and specify the size and style of the new window with Javascript. It is also common (and courteous) to add an informative bracket after the link saying something along the lines of "(opens new window)".

My experience has been that external Javascript files have no effect (or a possibly beneficial one because of reduced on-page code) as long as the URLs are not embedded.

eeek

6:58 am on Jun 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you are going to be playing with JS links, make sure you test your code in all browsers.

Indeed. It is always best if you design your page to work even when javascript is not available.

Spine

7:13 am on Jun 29, 2005 (gmt 0)

10+ Year Member



Thanks for the explanation.

The URLs that go with the nav menu appear in a <script> a the top of the page, and look like so

Menu1=new Array("example","home.php?com=showThisCat&cat=8","",0,19,174);

The sim spider can't seem to see these, but maybe Gbot will?

[edited by: Spine at 7:16 am (utc) on June 29, 2005]

wickedthoughtz

6:53 pm on Jun 29, 2005 (gmt 0)

10+ Year Member



Using CSS to do "rollover" behaviors sounds promising. I wasn't aware it could do that, but I'm incredibly uninformed in CSS, so would have to leave that option for an even further update.
I guess I'm slightly unclear as to what criterion makes a javascript link a good one or bad one. Here is one line of code from my page representing one javascript rollover...........

<TD
width="86" valign="top"><a href="AboutUs.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('menu-about us','','images/menu.jpg',1)"><img src="images/menu-AboutUs.jpg" name="menu-about us" width="86" height="41" border="0"></a></TD>
<TD

Thats the way Dreamweaver generates the code, and the "<a href = " is definitely inside the javascript code (which is at the top of the html coding and not in the actual body of the page. Does that make this a bad link, as far as spiderability is concerned? I have custom images these rollovers use, and my site is an art based site, so aesthetics are everything to me.
One solution I was toying with was making hidden layers underneath each rollover image with a plain text link that only bots would follow, but users wouldn't see. This would be used completely as a safeguard. As long as the links and titles of the links were accurate would this lead me down a road of problems? Even if these "hidden links" accurately represented the pages, could malicious competitors use an employed tactic such as that to get me in trouble with the search engines? I'm most eager to just get my javascript rollovers spiderable though.

Spine

7:33 pm on Jun 29, 2005 (gmt 0)

10+ Year Member



Obviously I'm not an expert, but I think that because you have this in your HTML <a href="AboutUs.htm" - you should be fine, even though there is other stuff in the tag, the URL is there where it 'should be'.

Not an expert though...

tedster

7:36 pm on Jun 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<a href = " is definitely inside the javascript code

Not in what you just posted. The javascript there is only the two event handlers (onmouseover and onmouseout) and they are INSIDE the anchor tag - the anchor tag is not inside the javascript. However, if there is an open <script> tag before that url and the matching close </script> tag is after the anchor element, then there is a problem.

<a onclick="openEnlarged(1026)" href="#">

The challenge here is the 1026, which I assume pulls an actula url from somewhere. If you have a tag like this:

<a onclick="openEnlarged('page.html')" href="#">

...you can make it spiderable (and have it pass PR, anchor text influence, and so on) like this:

<a onclick="openEnlarged('page.html');return false;" href="page.html">

tedster

7:41 pm on Jun 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



enu1=new Array("example","home.php?com=showThisCat&cat=8","",0,19,174);

The sim spider can't seem to see these, but maybe Gbot will?

Googlebot "may" try to spider anything that looks even remotely like a url - no matter where it is found. But even if such hidden urls do resolve for Gbot, you still get no PR passed and no anchor text influence.

This type of poking around happens with the version of Googlebot that Dijkgraaf mentioned in message #2 - not the regular crawler.

Spine

9:00 pm on Jun 29, 2005 (gmt 0)

10+ Year Member



Thanks Tedster.

This site will be a test of what can and can't be crawled by that new bot.

As for the 1026 in that example URL, I'm guessing that it's tied into a MySQL database somehow, as the site is dynamic and I can't see where the on-page info related to 1026 resides.