Solved

Microsoft JScript runtime error: 'window.opener.location' is null or not an object

Posted on 2011-03-11
6
1,553 Views
Last Modified: 2012-05-11
I get this error when trying to close my popup.

This worked fine in chrome
0
Comment
Question by:vbnetcoder
6 Comments
 

Author Comment

by:vbnetcoder
ID: 35110958
This is my ASP.net code that works fine in chrome
Imports System.Data
Imports System.IO

Partial Class CategoryEditPopup
    Inherits System.Web.UI.Page
    Dim clsProduct As New clsProduct
    Dim CategoryID As String
    Dim MainCategoryName As String
    Dim ImageCount As Integer

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        btnCancel.OnClientClick = "javascript:window.opener.location.reload();self.close();"
        btnRemove.OnClientClick = "javascript:window.opener.location.reload();self.close();"

        CategoryID = Request.QueryString("Category_ID")


        MainCategoryName = GetCategoryName(CategoryID)

        ImageCount = clsProduct.ReturnImageCountByCategoryID(CategoryID)

        If Not IsPostBack Then
            LoadCategoriesList()
            LoadFormInfo()

        End If

    End Sub
    Private Sub LoadFormInfo()

        Dim dr As SqlClient.SqlDataReader = clsProduct.ReturnSpecificCategoryDetailsSubMainDataReader(CategoryID)

        dr.Read()
        lblCategoryID.Text = dr("Category_ID")
        txtName.Text = dr("Category_Name")
        txtDescription.Text = dr("Category_Description")


        dr.Close()

        GetCategoryPath()

    End Sub
    Private Sub GetCategoryPath()

        lblCategoryPath.Text = "/" & clsProduct.ReturnCategoryPath(CategoryID)

    End Sub
    Private Sub LoadCategoriesList()

        Dim dr As SqlClient.SqlDataReader
        dr = clsProduct.ReturnCategoriesList(dr)
        ddCategories.Items.Clear()
        ddCategories.Items.Add("None")

        Do While dr.Read
            ddCategories.Items.Add(dr("Category_Name"))
        Loop

        dr.Close()

        MainCategoryName = GetCategoryName(CategoryID)

        If Not MainCategoryName = "" Then
            ddCategories.SelectedItem.Text = MainCategoryName
        End If


        ddCategories.Dispose()

    End Sub
    Private Function GetCategoryName(ByVal CategoryID As String) As String

        MainCategoryName = clsProduct.ReturnCategoryNameByCategoryID(CategoryID)
        Return MainCategoryName

    End Function
    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click

        If Not (Trim(txtName.Text) = "") Then
            Dim imgStream As Stream = FileUpload1.PostedFile.InputStream
            Dim imgLen As Integer = FileUpload1.PostedFile.ContentLength
            Dim imgContentType As String = FileUpload1.PostedFile.ContentType
            Dim imgName As String = FileUpload1.FileName
            Dim imgBinaryData As Byte() = New Byte(imgLen - 1) {}

            Dim n As Integer = imgStream.Read(imgBinaryData, 0, imgLen)

            clsProduct.UpdateCategory(CategoryID, txtName.Text, txtDescription.Text, ddCategories.Text, _
                                       imgBinaryData, imgName, imgContentType)
            'LoadCategoriesList()
            LoadFormInfo()

        End If

    End Sub

    Protected Sub btnRemove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRemove.Click
        clsProduct.DeleteCategoryByCategoryID(CategoryID)
    End Sub
    
    Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click

    End Sub

Open in new window

0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 35114680
Javascript code using to close ?

Raj
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 35114691
"javascript:window.opener.location.reload();self.close();" doesn't make any sense to me.  

window.open() opens a new window, window.location.reload() reloads the current window.  I don't understand what the two do together.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 35114774
@Dave: It is perfectly correct code
window.opener.location.reload() will reload the window that spawned the popup
self.close() will close the popup

We also need to see the code that opened the window and if the code you posted might live in an iframe
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 35114789
Never seen "window.opener.location.reload()" before.  Here's a page that claims one solution: http://social.msdn.microsoft.com/Forums/en/iewebdevelopment/thread/0c014e78-8d35-4df3-93da-7f6a30b4ed8b

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 35114800
That seems to be a vista+ option

Let's first see if it is not due to other things like
<a href="someurl" onclick="window.open(....)">click</a>
without a return false, which may unload the opener invisibly
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 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

13 Experts available now in Live!

Get 1:1 Help Now