最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - Check if javascript is enabled in browser - Stack Overflow

programmeradmin9浏览0评论

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

<noscript><meta http-equiv="refresh" content="0;url=.html"></noscript>

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?

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"></noscript>

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?

Share Improve this question edited Sep 29, 2010 at 7:56 asked Sep 28, 2010 at 15:18 user188962user188962
Add a ment  | 

3 Answers 3

Reset to default 3

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.

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 :)

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

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

发布评论

评论列表(0)

  1. 暂无评论