Solved

Javascript Popup Opens in Background in .NET Application

Posted on 2013-11-06
4
281 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

829 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