Open
Bug 163807
Opened 23 years ago
Updated 3 years ago
Cannot create a event in a parent window
Categories
(Core :: DOM: Events, defect, P5)
Tracking
()
NEW
People
(Reporter: ja, Unassigned)
Details
(Keywords: testcase)
Attachments
(1 file)
604 bytes,
text/html
|
Details |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1b) Gecko/20020820
Build Identifier: Build ID: 2002082008
I'm trying to create a "onclick" event in a parent window, but the event is
always triggered to actual window.
Reproducible: Always
Steps to Reproduce:
1.
var parent_window = window.opener;
var el_nazev = parent_window.document.createElement("span");
el_nazev.addEventListener("click",function() {
window.open("http://redsys-roman.iinfo.cz/");
},false);
window.close();
2. The "span" element is created in parent window, the child window, from which
was the element created is closed
3. Clicking on the "span" element causes a exception:
Error: [Exception... "Component returned failure code: 0x80004005
(NS_ERROR_FAILURE) [nsIDOMJSWindow.open]" nsresult: "0x80004005
(NS_ERROR_FAILURE)" location: "JS frame ::
http://redsys-roman.iinfo.cz/scripts/pertinent_links.pl?text_id=174&title=Muj&url=http://www.muni.cz&legend=No&type=1&add=1
:: anonymous :: line 47" data: no]
Source File:
http://redsys-roman.iinfo.cz/scripts/pertinent_links.pl?text_id=174&title=Muj&url=http://www.muni.cz&legend=No&type=1&add=1
Line: 47
Actual Results:
I got a exception described above.
Expected Results:
In specification of DOM Level 2 Events is not mentioned, that event should be
triggered to actual window.
Comment 2•23 years ago
|
||
The following code works. It creates the event attached to a span in the parent
window. Try this, let me know if you still have problems.
<HTML>
<SCRIPT>
var parent_window = window.opener;
var el_nazev = parent_window.document.createElement("span");
el_nazev.addEventListener("click",function() {
window.open("http://redsys-roman.iinfo.cz/");
},false);
txt_node = parent_window.document.createTextNode("THIS IS SPAN");
el_nazev.appendChild(txt_node);
parent_window.document.body.appendChild(el_nazev);
</SCRIPT>
<BODY>
THIS IS CHILD WINDOW
</BODY>
</HTML>
Reporter | ||
Comment 3•23 years ago
|
||
The code works. But what if you add window.close(); behind
"parent_window.document.body.appendChild(el_nazev);"?
My javascript console says:
Error: [Exception... "Component returned failure code: 0x80004005
(NS_ERROR_FAILURE) [nsIDOMJSWindow.open]" nsresult: "0x80004005
(NS_ERROR_FAILURE)" location: "JS frame :: http://pinda.iinfo.cz/~ja/event.html
:: anonymous :: line 6" data: no]
Source File: http://pinda.iinfo.cz/~ja/event.html
Line: 6
Comment 4•23 years ago
|
||
Confirming. I see the problem now. It has to do with closing the window after
modifying the parent page...
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 5•23 years ago
|
||
This testcase shows the problem but is not very readable, since the child
window is generated using document.write (its all in a single line)... the code
for the child window looks like this:
<HTML>
<SCRIPT>
var parent_window = window.opener;
var el_nazev = parent_window.document.createElement("span");
el_nazev.addEventListener("click",function() {
window.open("http://redsys-roman.iinfo.cz/");
},false);
txt_node = parent_window.document.createTextNode("THIS IS SPAN");
el_nazev.appendChild(txt_node);
parent_window.document.body.appendChild(el_nazev);
window.close();
</SCRIPT>
<BODY>
THIS IS CHILD WINDOW
</BODY>
</HTML>
Updated•23 years ago
|
Priority: -- → P3
Updated•16 years ago
|
Assignee: joki → nobody
QA Contact: vladimire → events
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•