Solved

java script error in internet explorer

Posted on 2011-03-11
12
328 Views
Last Modified: 2012-05-11
when I hit this code in IE

<input type="submit" name="btnCancel" value="Cancel" onclick="javascript:window.opener.location.reload();self.close();" id="btnCancel" />

I get the error:

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

THIS WORKS FINE IN CHROME WHERE I HAVE BEEN TESTING IT ALL ALONG
0
Comment
Question by:vbnetcoder
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 1

Expert Comment

by:janvanderwijk
ID: 35108956
Maby IE does't like that because the parent window may not be opened using Java script. Maybe the follwing will work:
opener.location.href =
or
opener.opener. .... and then whatever you want
0
 
LVL 9

Expert Comment

by:gery128
ID: 35109193
is the pop-up window blocker is on in IE?
0
 

Author Comment

by:vbnetcoder
ID: 35109226
It pops up but closing is the problem
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:vbnetcoder
ID: 35109267
I turned off the popup blockers and not I get this error:


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

Expert Comment

by:SAMIR BHOGAYTA
ID: 35109274
Hi, you have to call the javascript function with onClientClick event of any control.
0
 

Author Comment

by:vbnetcoder
ID: 35109289
samirbhogayta:

I don't know what you mean .. could you show me?
0
 
LVL 9

Expert Comment

by:gery128
ID: 35109372
are you using IE8 to test it? Then see this link:
http://social.msdn.microsoft.com/Forums/en/iewebdevelopment/thread/0c014e78-8d35-4df3-93da-7f6a30b4ed8b

You should change your approach to open modal dialog box for better compatibility.
0
 

Author Comment

by:vbnetcoder
ID: 35109507
It is IE 8
0
 
LVL 9

Expert Comment

by:gery128
ID: 35109587
Please see this link and check if the Security permission is same mentioned in this link:
http://social.msdn.microsoft.com/Forums/en/iewebdevelopment/thread/0c014e78-8d35-4df3-93da-7f6a30b4ed8b

Also, consider using other alternatives, like modal popup

http://stackoverflow.com/questions/4885765/window-opener-alternatives
0
 
LVL 9

Expert Comment

by:jkofte
ID: 35109898
can you check my article here ?

http://kadirselcuk.com/?p=78
0
 

Author Comment

by:vbnetcoder
ID: 35110015
jkofte:


I no very little about javascript this is what I was doing in my asp.net code that worked in Chrome

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ImageType = Request.QueryString("ImageType")
        ProductID = Request.QueryString("Product_ID")
     

        btnNo.OnClientClick = "javascript:window.opener.location.reload();self.close();"

    End Sub


should I change the line

   btnNo.OnClientClick = "javascript:window.opener.location.reload();self.close();"

to say something different?
0
 
LVL 9

Accepted Solution

by:
jkofte earned 500 total points
ID: 35147605
actually what you were doing should work. my code would close the window without yes/no prompt.

did you try to copy and paste the address of the "pop-up page" into IE from Chrome ?

if so, it is normal that it cannot find its opener in IE 8.

You should start testing from "Opener page" in IE and then click to open the pop-up page.

Both pages must be in IE. You can't manipulate a page in Chrome via an event from a page in IE.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

813 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