使用JavaScript跳至新的HTML页面 [英] Jumping to a new HTML page with JavaScript

查看:66
本文介绍了使用JavaScript跳至新的HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的HTML页面中,我需要检查是否已安装Adobe Flash Player.如果没有,我想自动跳到另一个HTML页面,以告诉用户需要Flash Player.

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

我正在使用JavaScript,使用' JavaScript Flash检测库'.

I'm using JavaScript to check if the Flash player is available, using the 'JavaScript Flash detection library'.

我的HTML页面的正文如下:

The body of my HTML page looks like this:

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

检测正常:我可以看到警报,但是找不到跳转到另一个HTML页面的方法.

The detection is working: I can see the alert, but I didn't find a way to jump to another HTML page.

有任何提示吗?

编辑:我没有提到的东西似乎有所不同:HTML页面是本地页面(从CD-ROM运行),我想跳转到位于当前目录中的HTML页面.

There is something I didn't mention which seems to make a difference: the HTML pages are local pages (running from a CD-ROM), and I'd like to jump to an HTML page which is located in the current directory.

推荐答案

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";

也许您也可以使用以下方法做到绝对:(未经测试.)

Maybe you could also do it absolute using this: (Not tested.)

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

问题是浏览器供应商的安全措施.Google有一些很好的信息

The problem are the security measures of the browser vendors. Google has some good information about it.

这篇关于使用JavaScript跳至新的HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆