Solved

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

Posted on 2011-03-11
6
1,641 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…
Suggested Courses

635 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