Solved

Javascript Popup Opens in Background in .NET Application

Posted on 2013-11-06
4
276 Views
Last Modified: 2013-12-08
Hi!

For several years our .NET application has opened a popup in the foreground every time. I use:

Page.ClientScript.RegisterStartupScript(GetType(String), "Popup", "window.open('STUDLogList.aspx','pop','width=900,height=450,top=312,left=190,scrollbars=1');", True)

Lately the popup has started to open in the background without any change in code. Do you have any suggestions to help this?

Searching Google I can see at lot of people have exactly the same problem and a lot of suggestions to help it but I cannot make it work.
0
Comment
Question by:Kim Neesgaard
  • 3
4 Comments
 
LVL 3

Expert Comment

by:mikeyd234
ID: 39627228
Is this behavior occurring on a specific browser or on all?
0
 

Author Comment

by:Kim Neesgaard
ID: 39627330
My company uses Internet Explorer but I have downloaded Chrome and here it doesn't work at all - no popup is shown.
0
 

Accepted Solution

by:
Kim Neesgaard earned 0 total points
ID: 39694860
I have found a solution!

Insert a Javascript function like this:

<script type="text/javascript" language="javascript">
    function PopupOpen()
{
    window.open('YourFile.aspx', '_blank', 'width=900,height=450,top=312,left=190,scrollbars=1')
}
</script>

and call the popup like this:

Dim csname1 As [String] = "PopupScript"
            Dim cstype As Type = Me.[GetType]()

            ' Get a ClientScriptManager reference from the Page class.  
            Dim cs As ClientScriptManager = Page.ClientScript

            ' Check to see if the startup script is already registered.  
            If Not cs.IsStartupScriptRegistered(cstype, csname1) Then
                Dim cstext1 As New StringBuilder()
                cstext1.Append("<script type=text/javascript> ")
                cstext1.Append("window.attachEvent('onload',PopupOpen) </script>")
                cs.RegisterStartupScript(cstype, csname1, cstext1.ToString())
            End If

This ensures that the popup code is the LAST to run. I have checked the solution and it works perfect for me.
0
 

Author Closing Comment

by:Kim Neesgaard
ID: 39704120
This solution simply works!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now