Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-03-11
6
Medium Priority
?
1,663 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 84

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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

661 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