check if Javascript is enabled and take actions

A

Anonymous

Guest
Hi,
I want to add a couple of pop-up boxes in my page, and I want to know :
1) is there a small piece of code that I must paste in my page which will check to see if the client has JS enabled?
2) do I use the <noscript> tag to enter the page that the user with no JS enabled will see?
3) if a user has JS enabled, do I need to check also if there are pop-up blockers, or it will be ok and my pop-up will open with no problem?

What I want basically is:
I have a link in the page ,which, if JS is enabled will open in a pop-up window when the user clicks on it, whereas, if JS is disabled, it will open in a new page, like plain, ordinary links

Thanks in advance
 
If you use this:

Code:
<a href="somepage.html" target="_blank" onclick="window.open(this.href,'somepage','width=600,height=400');return false;">click here</a>

Possible results:
  1. If JS is disabled, the onclick event will not be executed and the link opens in a new window as normal.
  2. If JS is enabled and no popup blockers exist, the onclick event is executed which opens the url in a popup window and cancels the regular link (return false does that).
  3. If JS is enabled and a popup blocker is active, nothing will happen. However, this is the normal effect from popup blockers and should be respected imho. If the user wants to open the link, they have to bypass the blocker (often by holding CTRL while clicking) or disable the blocker for your site.

Coditor
 
Back
Top