0

I am building a site which has javascript in it.

In my site if a user clicks on login or register button a modal popup will be shown.

What I need to know is if the user has disable javascript in his/her browser they should be sent to a normal html signup page (Like in imdb.com) when the user clicks the login link.

Give me some tips on what I should do to get result like that.

I am a newbie so don't be too harsh in your reply.

mplungjan
  • 169,008
  • 28
  • 173
  • 236
Kishore Kumar
  • 47
  • 1
  • 14
  • 3
    please search the site for similar questions first. http://stackoverflow.com/questions/8355359/redirect-to-another-page-if-javascript-is-disabled – Paul Collingwood Jan 07 '13 at 10:41
  • Neither of those "duplicate" questions are duplicates of this question. They are asking about redirecting (if JS is disabled) *when the page is loaded* not when a link is clicked. – Quentin Jan 07 '13 at 10:44
  • I did search for my question but didn't find one like mine. Thats why i asked for it. My apologies if my question is wrong. But pls try to understand what i ask. – Kishore Kumar Jan 07 '13 at 10:48
  • I re-wrote the question to make it clearer that you want to redirect on click. Next time please make such distinction much clearer, especially since you found examples that did NOT answer your question. Anyway you got your answer – mplungjan Jan 07 '13 at 10:51
  • @mplungjan - Should probably have removed the term "redirect", since that was what threw me. "navigate" would have been less confusing. – Alohci Jan 07 '13 at 11:01

2 Answers2

3

In short, you set dynamic onclick handler for your button and prevent the default event (in the example below with return false). If JavaScript is disabled, the original event (redirection) will work.

HTML:

<a href="/path/to/normal/sign/up.html" id="login">

JavaScript:

document.getElementById("login").onclick = function() {
    // show popup
    return false;
};
VisioN
  • 143,310
  • 32
  • 282
  • 281
0
  1. Have a normal link to the sign up page
  2. Add an event listener to create the modal
  3. Prevent the default behaviour of clicking on the link
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335