Not all browsers support JavaScript events and other featuressome, particularly pre4.0 browsers, have very limited support. With the Check Browser action, you can detect which browsers are being used by the visitors to your Website and redirect users to another page if you want to provide features that won't display correctly in older browsers. For example, if your page contains layers (covered in Lesson 9), you could create a page without the layers and redirect users with 4.0 or later browsers to the page that uses layers. Users with older browsers or with JavaScript turned off would remain on the page that doesn't use layers. In this exercise you will add a Check Browser behavior to one page and redirect the users with 4.0 or later browsers to another page. If you do use this feature, it can be good to keep the page that contains the Check Browser behavior very small so that it loads and redirects the visitor quickly. If it is too large, it might take a considerable amount of time to load, causing visitors to have to wait not only for that page to load but also for the one to which they are redirected to load. | | 1. | Open sequences.html from the explorations folder. Select the <body> tag by clicking <body> in the tag selector (in the lower-left corner of the Document window).
The action will be attached to the <body> tag to redirect a user when the page loads. You should see <body> displayed in the title bar of the Behaviors panel, indicating that the <body> tag is selected.
Note When the <body> tag is selected, all content in the document appears selected. | 2. | Click the plus sign (+) button in the Behaviors panel and choose Check Browser from the Add Behavior menu of actions.
The Check Browser dialog box opens.
| | | 3. | For both Netscape 4.0 and Internet Explorer 4.0 or later, choose Go to URL from the appropriate menu. For both Netscape and Internet Explorer; otherwise, choose Stay on this page. For Other browsers, choose Stay on this page.
When you use the Check Browser behavior, if you tried to use this behavior to redirect users with older browsers to another page, it would not work for anyone who uses a browser that does not support JavaScript or who simply turned off JavaScript.
Note To redirect all users to a different page, regardless of their browser version, you can use a meta tag refresh by choosing Insert > HTML > Head Tags > Refresh or by switching to the HTML category of the Insert bar and choosing Refresh from the Head menu. In the dialog box, type the URL that you want users redirected to in the Go to URL text field. If you want users to remain on the page for a certain length of time before the browser loads the page that you are redirecting them to, type the time in seconds into the Delay text field. The Refresh this document option reloads this page in the browser. | 4. | Click the Browse button next to the URL text field and locate the poses.html file in the Lesson_08_Interactivity/explorations folder.
The poses.html file is the page to which users of the latest browsers will be redirected.
| | | 5. | Click OK to insert the JavaScript into your page.
![](/books/4/198/1/html/2/images/dw8_ch08_024.jpg) The onLoad event appears with the corresponding Check Browser action in the Behaviors panel.
| 6. | Save the file and test the page in your browser.
| If you do not have a 4.0 or later version of Internet Explorer or Netscape, you remain on the static page. This includes such commonly used browsers such as Firefox, Safari, and Opera. If you have a 4.0 or later version of Internet Explorer or Netscape, you might briefly see the sequences.html page before the browser redirects you to the other page, poses.html. You can close the sequences.html file. |