首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用jQuery从一个html页面链接到另一个html页面

问使用jQuery从一个html页面链接到另一个html页面
EN

Stack Overflow用户
提问于 2015-08-18 12:42:49
回答 1查看 268关注 0票数 0
代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <link rel="stylesheet" type="text/css" href="/Users/skhare/myFirstStyleSheet.css">

  <script>
    $(document).ready(function() {
    $('#name').click(showTables(a){                
                        alert(a);
    });
    });

  </script>
</head>

<body>s
    <div id="placeholder"></div>
    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>

    <script>
          $.getJSON('/Users/skhare/reportSuiteList.json',   function(reportSuiteList) {
    var output="<table id=tableStyle>";
    output+="<tr>" + "<th>" + "id" + "</th>" + "<th>" + "name" + "</th>" + "<th>" + "stage" + "</th>" + "<th>" + "DWH" + "</th>" + "</tr>";
    for (var i in reportSuiteList.suites)
    {
        output+="<tr>" + "<td>" + reportSuiteList.suites[i].REPORTSUITE_ID + "</td>" + "<td>" + "<a href=# id = name onClick = showTables(reportSuiteList.suites[i].name>" + reportSuiteList.suites[i].REPORTSUITE_NAME + "</a>" + "</td>" + "<td>" + reportSuiteList.suites[i].STAGING_DATABASE + "</td>" + "<td>" + reportSuiteList.suites[i].DWH_DATABASE + "</td>" + "</tr>";
    }

        output+="</table>";
        document.getElementById("placeholder").innerHTML=output;

});

代码语言:javascript
复制
</body>
</html>

在参数列表之后,我得到的错误是缺少)。我检查了它,但是我的(,{似乎是平衡的,我找不到我缺少的)。请帮帮忙

EN

回答 1

Stack Overflow用户

发布于 2015-08-18 13:28:54

jQuery不是必需的,window.location.replace(...)将最好地模拟HTTP重定向。

它比使用window.location.href =更好,因为replace()不会将原始页面放在会话历史中,这意味着用户不会陷入无休止的后退按钮失败。如果你想模拟某人点击一个链接,可以使用location.href。如果要模拟HTTP重定向,请使用location.replace.

例如:

代码语言:javascript
复制
// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");

// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32063687

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档