-2

I'm having problems with detecting Javascript. I've created a jQuery Popup window which is working only for users who has javascript enabled. However if their browser has JS disabled, I'd like to redirect them to index.php WHEN they click on the button.

So basically if someone has JS enabled he/she would get the popup window, and if they don't have, they would have been redirected.

Is it possible? Also if would this work on mobile devices aswell?

1
  • 1
    If it's an a-tag, just provide a correct href Commented Feb 13, 2013 at 14:09

2 Answers 2

4

There is a meta tag that will allow you to do this, just keep in mind it can't go in the body and needs to be in the head of the document.

<noscript>
    <meta http-equiv="Refresh" content="0; URL=../error/errorjs.jsp" />
</noscript>
Sign up to request clarification or add additional context in comments.

2 Comments

I would actually only need to redirect the person if they don't have Javascript enabled.
hence the noscript tags. it will ONLY redirect if javascript is disabled.
2

This technique is called hijax

Create a link <a href="index.php">..</a>

And attach to it a javascript event that disable the normal flow

If javascript is enabled, it will show the popup, otherwise the link will work as normal..

2 Comments

if you're using jQuery you can use event.preventDefault() to stop the normal functionality of an <a> tag. api.jquery.com/event.preventDefault
Could you please elaborate it a little bit more? I've just downloaded a jQuery popup window and I don't know where to paste what :/

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.