Switching to a new HTML page with JavaScript

In my HTML page, I need to check if Adobe Flash Player is installed. If not, I want to automatically switch to another HTML page to inform the user that a Flash player is required.

I use JavaScript to check if a Flash player is available using the JavaScript JavaScript Detection Library .

The body of my HTML page is as follows:

<body> <script type="text/javascript"> if(!FlashDetect.installed) { alert("Flash 9.0.115 is required to enjoy this site."); } </script> ... ... 

Detection works: I see a warning, but I have not found a way to go to another HTML page.

Any clues?

Edit:. I did not mention that it seems to matter: HTML pages are local pages (from the CD), and I would like to go to the HTML page that is in the current directory.

+5
source share
2 answers
 window.location.href = "http://stackoverflow.com"; 

For local files, this should work if you know the relative path: (In your case, this works.)

 window.location.href = "someOtherFile.html"; 

Perhaps you could also make it absolute using this: (Not tested.)

 window.location.pathname = "/path/to/another/file.html/"; 

The problem is with browser vendor security measures. Google has some good info on this.

+19
source

Be very careful with instant JavaScript redirects. Error detection scenarios may be incorrect (*), therefore it is best to allow the user to independently solve problems with the flash or not using any manual redefinition or just use the backup content.

The entry in location.href works, but it can “break the back button - if the user clicks back and your page refreshes the page forward, they are unlikely to be happy. Location.replace ('...') avoids this problem.

(* - there are two approaches to detecting Flash, none of them is reliable. Creating a Flash instance and sniffing for it is interrupted using software such as FlashBlock, or just slow loading, and sniffing for plugins is not directly standardized and probably , more obscure platforms: Adobe's own code at http://www.adobe.com/devnet/flashplayer/articles/future_detection_print.html ultimately resorts to sniffing the UA, ugh string.)

+4
source

All Articles