Tuesday, March 13, 2012

Strange Popup JS window behavior

Hi,

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops
= 'height='+h+',width='+w+',top='+wint+',left='+winl +',scro
llbars='+scroll+',resizable=0'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) {
win.window.focus(); }
}

between <head> tags

Page.RegisterStartupScript("details", "<script
language='JavaScript'>NewWindow
('showDetails.aspx','details',630,200,'yes');</script>")

is the code when I open a popup JS window

In design mode in VS.NET 2003 it works just fine, but when
I run it on from my production server the popup window
hides behind the calling window.

Any ideas?

TIA

/KennethHey Kenneth,

It works fine on my local machine, outside of the VS.NET environment.

I'm wondering if it is a timing thing where the main page is still rendering
its contents and somehow steals back the focus? Maybe there's a delay while
the page is compiled?

Ken

"Kenneth" <kenneth.philp@.chello.se> wrote in message
news:06b501c3da2d$c5d46380$a101280a@.phx.gbl...
> Hi,
> function NewWindow(mypage, myname, w, h, scroll) {
> var winl = (screen.width - w) / 2;
> var wint = (screen.height - h) / 2;
> winprops
> = 'height='+h+',width='+w+',top='+wint+',left='+winl +',scro
> llbars='+scroll+',resizable=0'
> win = window.open(mypage, myname, winprops)
> if (parseInt(navigator.appVersion) >= 4) {
> win.window.focus(); }
> }
> between <head> tags
> Page.RegisterStartupScript("details", "<script
> language='JavaScript'>NewWindow
> ('showDetails.aspx','details',630,200,'yes');</script>")
> is the code when I open a popup JS window
> In design mode in VS.NET 2003 it works just fine, but when
> I run it on from my production server the popup window
> hides behind the calling window.
> Any ideas?
> TIA
> /Kenneth
Is there in asp.net any property you can set that tells
the window to stay on top of all other windows?

In JS 1.2 there is a 'alwaysRaised' parameter to
the 'window.open' function, but I can't get that working
either.

/Kenneth

>--Original Message--
>Hey Kenneth,
>It works fine on my local machine, outside of the VS.NET
environment.
>I'm wondering if it is a timing thing where the main page
is still rendering
>its contents and somehow steals back the focus? Maybe
there's a delay while
>the page is compiled?
>Ken
>"Kenneth" <kenneth.philp@.chello.se> wrote in message
>news:06b501c3da2d$c5d46380$a101280a@.phx.gbl...
>> Hi,
>>
>> function NewWindow(mypage, myname, w, h, scroll) {
>> var winl = (screen.width - w) / 2;
>> var wint = (screen.height - h) / 2;
>> winprops
>>
= 'height='+h+',width='+w+',top='+wint+',left='+winl +',scro
>> llbars='+scroll+',resizable=0'
>> win = window.open(mypage, myname, winprops)
>> if (parseInt(navigator.appVersion) >= 4) {
>> win.window.focus(); }
>> }
>>
>> between <head> tags
>>
>> Page.RegisterStartupScript("details", "<script
>> language='JavaScript'>NewWindow
>> ('showDetails.aspx','details',630,200,'yes');</script>")
>>
>> is the code when I open a popup JS window
>>
>> In design mode in VS.NET 2003 it works just fine, but
when
>> I run it on from my production server the popup window
>> hides behind the calling window.
>>
>> Any ideas?
>>
>> TIA
>>
>> /Kenneth
>.
Perhaps, on this form I call for the JS function with two
calls, one from a button (doesn't work) and one from a
buttoncolumn in a grid (that works).

From the grid's ItemCommand I do:

If e.CommandName = "Change" Then
Page.Register...
End If

and from the Button_Click event I do:

Page.Register...

with identical calls.

What to do?

/Kenneth

>--Original Message--
>Hey Kenneth,
>It works fine on my local machine, outside of the VS.NET
environment.
>I'm wondering if it is a timing thing where the main page
is still rendering
>its contents and somehow steals back the focus? Maybe
there's a delay while
>the page is compiled?
>Ken
>"Kenneth" <kenneth.philp@.chello.se> wrote in message
>news:06b501c3da2d$c5d46380$a101280a@.phx.gbl...
>> Hi,
>>
>> function NewWindow(mypage, myname, w, h, scroll) {
>> var winl = (screen.width - w) / 2;
>> var wint = (screen.height - h) / 2;
>> winprops
>>
= 'height='+h+',width='+w+',top='+wint+',left='+winl +',scro
>> llbars='+scroll+',resizable=0'
>> win = window.open(mypage, myname, winprops)
>> if (parseInt(navigator.appVersion) >= 4) {
>> win.window.focus(); }
>> }
>>
>> between <head> tags
>>
>> Page.RegisterStartupScript("details", "<script
>> language='JavaScript'>NewWindow
>> ('showDetails.aspx','details',630,200,'yes');</script>")
>>
>> is the code when I open a popup JS window
>>
>> In design mode in VS.NET 2003 it works just fine, but
when
>> I run it on from my production server the popup window
>> hides behind the calling window.
>>
>> Any ideas?
>>
>> TIA
>>
>> /Kenneth
>.
Yes, it was a time delay problem.

I tried to include 'setTimeout' upon calling the JS
function with a delay with 200 ms and it all works just
fine.

/Kenneth

>--Original Message--
>Hey Kenneth,
>It works fine on my local machine, outside of the VS.NET
environment.
>I'm wondering if it is a timing thing where the main page
is still rendering
>its contents and somehow steals back the focus? Maybe
there's a delay while
>the page is compiled?
>Ken
>"Kenneth" <kenneth.philp@.chello.se> wrote in message
>news:06b501c3da2d$c5d46380$a101280a@.phx.gbl...
>> Hi,
>>
>> function NewWindow(mypage, myname, w, h, scroll) {
>> var winl = (screen.width - w) / 2;
>> var wint = (screen.height - h) / 2;
>> winprops
>>
= 'height='+h+',width='+w+',top='+wint+',left='+winl +',scro
>> llbars='+scroll+',resizable=0'
>> win = window.open(mypage, myname, winprops)
>> if (parseInt(navigator.appVersion) >= 4) {
>> win.window.focus(); }
>> }
>>
>> between <head> tags
>>
>> Page.RegisterStartupScript("details", "<script
>> language='JavaScript'>NewWindow
>> ('showDetails.aspx','details',630,200,'yes');</script>")
>>
>> is the code when I open a popup JS window
>>
>> In design mode in VS.NET 2003 it works just fine, but
when
>> I run it on from my production server the popup window
>> hides behind the calling window.
>>
>> Any ideas?
>>
>> TIA
>>
>> /Kenneth
>.
Glad to hear you made some progress!

"Kenneth" <kenneth.philp@.chello.se> wrote in message
news:0cfd01c3daac$1bc17840$a301280a@.phx.gbl...
> Yes, it was a time delay problem.
> I tried to include 'setTimeout' upon calling the JS
> function with a delay with 200 ms and it all works just
> fine.
> /Kenneth
Glad to hear you made some progress!

"Kenneth" <kenneth.philp@.chello.se> wrote in message
news:0cfd01c3daac$1bc17840$a301280a@.phx.gbl...
> Yes, it was a time delay problem.
> I tried to include 'setTimeout' upon calling the JS
> function with a delay with 200 ms and it all works just
> fine.
> /Kenneth

0 comments:

Post a Comment