Solved

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

Posted on 2011-03-11
6
1,612 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 83

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 83

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

738 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