views:

93

answers:

3

I have this code which checks if js is enabled and redirects:

<noscript><meta http-equiv="refresh" content="0;url=http://www.domain.se/act.html"&gt;&lt;/noscript&gt;

However, I wonder if this is SE friendly...

This because I have added my website url to yahoo recently, and instead of the title appearing in the search results, the text from "aktivera_javascript.html" above appears. Why is that?

Thanks

UPDATE:

If the code above isn't proper for checking js availability, then what other method should I use instead?

+2  A: 

The noscript tag is for user agents that can't execute script. Since the Yahoo! spider is one of those agents, I would guess (but can't be certain) that it respects the content of the noscript tag and therefore the HTTP-refresh directive contained within. The result is that it thinks your site lives at http://www.skuffen.se/aktivera_javascript.html, and displays that content in search results.

To fix the issue I would suggest either:

  1. Use progressive enhancement to ensure the basic content is available without Javascript, and layer advanced features on top. User agents without Javascript won't know any different, and those with will get a richer experience.
  2. Simply use the noscript tag as a warning rather than a full redirect to another page, see How to check browser's JavaScript is enabled or not.
roryf
I haven't updated the site... So what other method should I use to check if js is enabled?
Camran
@Camran edited answer with suggestions
roryf
If I use noscript tag with a warning, wont the search engines still read that and display it in the search results?
Camran
@roryf: The progressive enhancement link has an extraneous "1." at the end of the URL.
Tim Rourke
@camran only if that's the first text on your site. look at how SO does it, using an empty `noscript` tag at the top and position the real one (which is last in the markup) over it.
roryf
@Tim Rourke thanks
roryf
A: 

I thought you don't understand this tag. the content of noscript will only shown wheter script (like JavaScript) isn't enable. (Most) Search Engines can't understand JS and execute the content von noscript. So in your case they follow the url.

But be carefull. With this method you can get penalty very fast. noscript is most used to show the user a notification, that javascript is disabled.

Sebastian Thiele
Yes but if I have a notification then wont search engines follow that noscript as you say, and display the notification in the search results?
Camran
Yes they would. But you can add the rel="nofollow" atribute to your link. The mos SE don't follow this links. Or you can block the site by the robots.txt. And you can wrap the information to the user in an image.
Sebastian Thiele
A: 

Personally, I think progressive enhancement is the way to go. Regardless of that you could try something like:

have people arrive at a non-js page by default. on the page have a script that is run on load:

<script type="text/javascript">
  window.location.href = 'page-with-javascript.html';
</script>

if the user has javascript enabled, they'll immediately be taken to the javascript friendly version.

but yeah.. progressive enhancement :)

clocKwize