check if Javascript is enabled and take actions

Javascript coding ..

Moderators: macek, egami, gesf

ktsirig
New php-forum User
New php-forum User
Posts: 36
Joined: Mon Sep 19, 2005 12:22 pm

check if Javascript is enabled and take actions

Postby ktsirig » Tue Apr 11, 2006 12:26 pm

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

User avatar
Coditor
New php-forum User
New php-forum User
Posts: 243
Joined: Wed Feb 01, 2006 9:18 am
Location: Netherlands
Contact:

Postby Coditor » Wed Apr 12, 2006 12:20 am

If you use this:

Code: Select all

<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


Return to “JavaScript”

Who is online

Users browsing this forum: No registered users and 1 guest