[RESOLVED] [vs2005] center child window
hi,
im opening a child window by injecting code through gridview rowdatabound.
and also at the same time i wanted to center the child window through the function leftmargin(); but the function does not returning any values when object is triggered.
Code:
DirectCast(e.Row.FindControl("pb_editImage"), Image).Attributes.Add("onclick", "window.open('popup_window.aspx?id=" & e.Row.DataItem("id") & "','win_title','menubar=no,status=no,toolbar=no,scrollbars=no,width=540px,height=400px, left=leftmargin();').focus();")
Code:
<script type="text/javascript" >
function leftmargin(){
var a ;
a = (screen.width - width)/2;
return a;
}
</script>
Re: [vs2005] center child window
You're putting in the call to leftmargin() as part of a string. To have it called as a function, it needs to be outside of the string context:
Code:
DirectCast(e.Row.FindControl("pb_editImage"), Image).Attributes.Add("onclick", "window.open('popup_window.aspx?id=" & e.Row.DataItem("id") & "','win_title','menubar=no,status=no,toolbar=no,scrollbars=no,width=540px,height=400px, left='+leftmargin()).focus();")
Also make sure that the "width" variable in your function has a value.
Re: [vs2005] center child window
hey,
the same did not work and it return an error expected ")". heres the markup.
Code:
onclick="window.open('performance_bond.aspx?id=5','win_title','menubar=no,status=no,toolbar=no,scrollbars=no,width=540px,height=450px, left='+leftmargin();).focus();"
Re: [vs2005] center child window
if you look closely, Samba's code does not have the semi-colon you added to leftmargin(). a semi-colon in JavaScript is a line terminator, and you're not terminating that line until you call the focus() method.
Re: [vs2005] center child window
hey,
I remember doing that but it also return an error message WIDTH is undefined. But the markup includes the width property.
Code:
onclick="window.open('performance_bond.aspx?id=5','win_title','menubar=no,status=no,toolbar=no,scrollbars=no,width=540px,height=450px, left='+leftmargin()).focus();"
Re: [vs2005] center child window
use just numbers; get rid of the "px."
Re: [vs2005] center child window
Quote:
Originally Posted by
kows
use just numbers; get rid of the "px."
I already do that,regardless of having "px" or not suffix in height and width it works fine. Only that error comes in when I derived left value from function.
And that did not fix the error of undefined width as well.
Thanks.
Re: [vs2005] center child window
Oh. In your function, you never define width, just like Samba said:
Quote:
Originally Posted by
SambaNeko
Also make sure that the "width" variable in your function has a value.
Re: [vs2005] center child window
Quote:
Originally Posted by
kows
Oh. In your function, you never define width, just like Samba said:
OMG I totally miss that.
It seems to work fine now with a fix value in width function.
I did not realize width is not a reserve keyword in js.