【问题标题】:how to open a pop up window to a link in gridview如何在gridview中打开一个指向链接的弹出窗口
【发布时间】:2014-01-10 14:58:39
【问题描述】:

我正在尝试在 java 脚本中为我的网格视图构建一个弹出窗口函数,但我无法打开该窗口。

var oldgridcolor;
function SetMouseOver(element) {
    oldgridcolor = element.style.backgroundColor;
    element.style.backgroundColor = '#ffeb95';
    element.style.cursor = 'pointer';
    element.style.textDecoration = 'underline';
}
function SetMouseOut(element) {
    element.style.backgroundColor = oldgridcolor;
    element.style.textDecoration = 'none';

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

    if (r == true) {
        window.location = host + newHost;
    }
    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)";
    }

任何帮助将不胜感激。

【问题讨论】:

  • 实现 window.open 而不是 window.location window.open('your page','name','width=200,height=200');

标签: c# javascript asp.net gridview


【解决方案1】:

请尝试一下,它可能对你有帮助。

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

    if (r == true) {
        //window.location = host + newHost;

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

【讨论】:

  • 感谢您的快速回复和帮助。我无法让 javascript 重定向到所需的网页,因为它打开了“服务器错误应用程序 - 找不到资源”的窗口。谢谢
  • 只需提醒您的主机 + newHost 变量,它是否显示您的预期网址
  • 为迟到的回复道歉,我仍然无法访问预期的网址。非常感谢您的时间和帮助。
  • 如果您能找到正确的 URL,并且如果我的回复有用,则将其标记为答案。谢谢
  • 您好,感谢您的回复。如何将弹出窗口定向到“about.aspx”页面?谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-07-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多