Redirecting the User with a Link
You can check for the existence of JavaScript and then seamlessly redirect, or send users to another page, depending on if they have JavaScript turned on. This example shows you how to embed the redirection in a link. We’ll use two HTML pages and one JavaScript file. The first HTML page, Script 2.9, gives the user the link to click. Script 2.10 is the JavaScript file, and Script 2.11 is the HTML page the user is redirected to if they have JavaScript enabled. Figure 2.6 shows the starting point for users. When they click the link, they’ll be taken to one of two pages, depending on whether or not they have JavaScript.
Figure 2.6. This page has the link that contains the redirection code.
Script 2.9. This HTML ...
Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.