473,322 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problem with window opener in IE

Hi

This works fine and adds a new element to the list:
document.forms['formname'].elements['listname'].options[0] = new
Option('foo', 'bar');
... but using the following code in a popup window - IE crashes or tells
me that the server threw an exception:
window.opener.document.forms['formname'].elements['listname'].options[0]
= new Option('foo', 'bar')
The code works just fine in Firefox. Could someone give me at hint on
what's wrong here?

Kind regards Søren
Oct 20 '05 #1
3 9205
Soren Schimkat <sc******@noemail.hum.aau.dk> writes:
IE crashes or tells me that the server threw an exception:

window.opener.document.forms['formname'].elements['listname'].options[0]
= new Option('foo', 'bar')

The code works just fine in Firefox. Could someone give me at hint on
what's wrong here?


Probably that you are adding an instance of Option from the current
document to a select from another document. I would try using the "Option"
constructor function from the other window, i.e., something like:

var otherWindow = window.opener;
otherWindow.document.forms['formname'].elements['listname'].options[0] =
new otherWindow.Options('foo','bar');

Not sure whether it works, though. My tests are inconclusive :)
To avoid this cross-page DOM scripting, you could put a function on the
original page to do the work, and just call it from the opened page.

<script type="text/javascript">
function addOption(text,value) {
document.forms['formname'].elements['listname'].options[0] =
new Option(text,value);
}
</script>

and then just do
window.opener.addOption('foo','bar');
in the opened window.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Oct 20 '05 #2
[snip]


To avoid this cross-page DOM scripting, you could put a function on the
original page to do the work, and just call it from the opened page.

yes offcourse .. that's the way to do. It works fine now. :-)

Tak for hjælpen.

mvh Søren


<script type="text/javascript">
function addOption(text,value) {
document.forms['formname'].elements['listname'].options[0] =
new Option(text,value);
}
</script>

and then just do
window.opener.addOption('foo','bar');
in the opened window.
/L

Oct 21 '05 #3
[snip]


To avoid this cross-page DOM scripting, you could put a function on the
original page to do the work, and just call it from the opened page.

yes offcourse .. that's the way to do. It works fine now. :-)

Tak for hjælpen.

mvh Søren


<script type="text/javascript">
function addOption(text,value) {
document.forms['formname'].elements['listname'].options[0] =
new Option(text,value);
}
</script>

and then just do
window.opener.addOption('foo','bar');
in the opened window.
/L

Oct 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Daniel Andersen | last post by:
Hi, Does anyone here know of a way of tracking the window that launched a popup window besides using window.opener? The problem i'm having is that the popup window submits a form within itself...
1
by: MrFez | last post by:
I have an webform from which I open a child window to display a calendar. When a date is selected in the calendar window it attempts to set the value of a textbox in the main (parent) window by...
5
by: Dave | last post by:
I see this problem in IE but not Firefox. I have a page that opens a second page as a dialog box. If the Dialog is relaunched from a second instance on the page the Dialog window is reused, the...
1
by: fogwolf | last post by:
First a basic outline of what I am trying to do: I want to have a page spawn a pop-up when you click "submit" on its form. On this pop-up page there will be another form. When you click "submit"...
19
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). ...
2
by: RWC | last post by:
Hello, I am new to JavaScript but until now, have felt my way along fairly successfully. I have a page showing an image to the user. I use window.open to open a separate page, listing a bunch...
1
by: MrFez | last post by:
I have an webform from which I open a child window to display a calendar. When a date is selected in the calendar window it attempts to set the value of a textbox in the main (parent) window by...
7
by: MrFez | last post by:
Through some investigation it appears that selecting "Every visit to the page" for the IE caching setting "Check for new version of stored pages" causes the window.opener property of child windows...
5
by: asadhkhan | last post by:
I have the following code which works correctly in IE 6, but in IE 7, Fire Fox 2.0 and Netscape 8 it does not work. I have a main page where a button calls this pop-up and uploads a file once you...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.