我试图在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)";
}
任何帮助将不胜感激。
请尝试一下,它可能会对您有所帮助。
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;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句