JavaScript的加载按钮单击页面 [英] JavaScript load a page on button click

查看:243
本文介绍了JavaScript的加载按钮单击页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在这里做一个非常简单的任务,我想可以点击页面上的一个按钮,并把它带我到另一个网页。我曾尝试window.location.href,和一堆其他的东西,它什么都不做。我尝试了多种不同的平台和不同的浏览器,都具有相同的结果。

I am trying to do a very simple task here, I would like to be able to click a button on a page and have it take me to another page. I have tried window.location.href, and a bunch of other things and it does nothing. I have tried different platforms and different browsers, all with the same result.

我知道,它可以调用一个函数,但我只是不能得到新的页面加载。另外这是在我的本地文件系统,这两个网页住在同一水平(但我也试图加载像www.apple.com外部页)。

I know that it can call a function but I just cannot get the new page to load. Also this is all in my local file system and both pages live at the same level (but I have also tried to load an external page like www.apple.com).

有什么想法?

谢谢
帕特里克

Thanks Patrick

推荐答案

简单code重定向页面

Simple code to redirect page

<!-- html button designing and calling the event in javascript -->
<input id="btntest" type="button" value="Check" 
       onclick="return btntest_onclick()" />

<script language="javascript" type="text/javascript">
function btntest_onclick() 
{
    window.location.href = "http://www.google.com";
}
</script>

这篇关于JavaScript的加载按钮单击页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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