Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

IE8 - Cannot inject into window.opener #2214

Closed
ibolmo opened this Issue · 3 comments

4 participants

@ibolmo
Owner

(from Lighthouse)

I have a page that opens a popup. From that page, I grab several values from the previous and the user picks which records to save. After clicking Save, it changes a variable to false onthe parent (window.opener), calls a function, injects a hidden element (to simulate the Submit button being clicked), and submits the form. In some cases, the popup will not be opened, so the actual submit button would be functional.

It works fine in Firefox 3.6.3, but not in IE 8.0.6001.18702. I've attached a zip file that is a very simple example which also worked/didn't work like the above version I described.

To make sure IE didn't block the popup from creating an element, I used window.opener.document.createElement('input'), set the correct attributes (setAttribute), and appended the element using appendChild. That worked, so I think inject needs a bit of work.

Attached file

@theprawn

Just ran into this issue myself

@GCheung55
Collaborator

I tested the issue in IE9 and got the following error: "DOM Exception: HIERARCHY_REQUEST_ERR (3)"

It's more of an issue when creating a new element with new Element than it is the inject method.

The jsfiddle was from someone else who had the same problem. Seems that IE doesn't allow injecting elements created in another window. Which means the element has to be created in window.opener's scope.

Anyways, I had issue when doing new window.opener.Element('div') because IE gave me the following error: "Invalid procedure call or argument". I haven't dug into what could be producing this error yet.

I tested this by having two windows, one parent, one child, on the same domain: http://fiddle.jshell.net/QUM5g/7/show/

The jsfiddle will open a child window where you can open developer tools to plugin the following code, which seems to work:

var win = window.opener;

var p = win.$(win.document.createElement('p'));
p.set('text', 'hello');
p.inject($(win.document.body),'top')
@arian
Owner

new Element creates an element in the current document. You can't simply move that to another document (See notes of appendChild: https://developer.mozilla.org/en-US/docs/DOM/Node.appendChild?redirectlocale=en-US&redirectslug=DOM%2Felement.appendChild#Notes)

@arian arian closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.