简体   繁体   English

如何在GridView中打开一个链接的弹出窗口

[英]how to open a pop up window to a link in gridview

I am trying to build a pop-up window function in java script for my grid view and I cannot get the window to open up. 我试图在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;
}

code behind 背后的代码

 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)";
    }

Any help would be very much appreciated. 任何帮助将不胜感激。

Please try it, it may help you. 请尝试一下,它可能会对您有所帮助。

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM