【问题标题】:how to open an html page using html5 [closed]如何使用html5打开一个html页面[关闭]
【发布时间】:2013-05-31 10:49:23
【问题描述】:

我必须在单击按钮时从同一文件夹中调用其他本地 html 页面。我怎么称呼它。给定

$("#nextbutton").click(function(){
    //alert('heretest')
    window.location.href = 'main.html';
});

但不工作。

【问题讨论】:

  • 您需要使用完整的真实 URL,而不仅仅是文件名。
  • 不行还是不行
  • 你试过链接吗?
  • 不工作,如此描述!
  • @CodingDecoding 可能原因:1) 没有包含jQuery,2) 在#nextbutton 存在之前执行此代码,3) 多个元素与id="nextbutton",4) 文件不存在, 5) #nextbutton 不存在。

标签: javascript jquery html


【解决方案1】:

点击按钮?我会建议

HTML:

<input type = "button" onclick = "openpage()" value = "open page">

JavaScript:

function openpage()
{
window.location.assign("http://www.yoursite.com/main.html");
}

但是为什么不直接使用链接呢?

<a href = "main.html">Main page</a>

您的问题很难理解。我认为这就是你想要的。

【讨论】:

  • 终于工作了。由于其他页面在同一页面上重叠,因此 y 无法看到输出。谢谢4 :)
  • @CodingDecoding 很好:)
  • -我曾经为这么一个小而愚蠢的问题打过标记,哈哈
猜你喜欢
  • 2015-02-24
  • 2011-11-02
  • 2012-10-10
  • 1970-01-01
  • 2021-12-13
  • 1970-01-01
  • 2017-09-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多