HTTP 404错误 - javascript网址代码 [英] HTTP 404 error - javascript url code

查看:73
本文介绍了HTTP 404错误 - javascript网址代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JavaScript来允许用户通过单击gridview上的行重定向到网址。目前,我目前遇到以下错误(无法找到资源。一个http 404错误。)代码中是否有我遗漏的东西,以使其工作。



I am using JavaScript to allow users to redirect to a url by clicking the rows on gridview. Currently, I am currently experiencing the following error (The resource cannot be found. A http 404 error.) Is there something I am missing in the code, to get this to work.

function SetMouseDown(element) {
    var r = confirm('Are you sure?');
    var url = window.location.pathname;
    var pathArray = url;
    var host = pathArray[1];
    var newHost = 'About.aspx';

    if (r == true) {
        window.open(host + newHost, 'name', 'width=200,height=200');
    }
    else {
        alert('it didnt work');
    }
    return false;
}







protected void gvrecords_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         e.Row.Attributes["onmouseover"] = "javascript:SetMouseOver(this)";
         e.Row.Attributes["onmouseout"] = "javascript:SetMouseOut(this)";
         e.Row.Attributes["onmousedown"] = "javascript:SetMouseDown(this)";
     }





非常感谢您的帮助和时间。



Many thanks for your help and time.

推荐答案

路径名 [ ^ ]属性将返回除主机之外的所有



你要找的是这样的:



The pathname[^] property will return everything except the host.

What you're looking for is something like this:

var protocol = window.location.protocol;
var host = window.location.host;
var newHost = 'About.aspx';

var url = protocol + '//' + host + '/' + newHost;
window.open(url);





各种浏览器具有内置或扩展功能来调试JavaScript。这些将允许您调试JavaScript,并尝试查看某些代码的作用以及各种对象所代表的内容。



Chrome的开发者工具 [ ^ ]

Internet Explorer的开发人员工具 [ ^ ]

FireFug for FireFox [ ^ ]



Various browsers have capabilities, either built-in or by an extension, to debug JavaScript. These will allow you to debug your JavaScript, and experiment to see what certain code does and what various objects represent.

Chrome's developer tools[^]
Internet Explorer's developer tools[^]
Firebug for FireFox[^]


这篇关于HTTP 404错误 - javascript网址代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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