Solved

Javascript Popup Opens in Background in .NET Application

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

747 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

10 Experts available now in Live!

Get 1:1 Help Now