473,698 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.d ocument.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 9218
Soren Schimkat <sc******@noema il.hum.aau.dk> writes:
IE crashes or tells me that the server threw an exception:

window.opener.d ocument.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.doc ument.forms['formname'].elements['listname'].options[0] =
new otherWindow.Opt ions('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,val ue);
}
</script>

and then just do
window.opener.a ddOption('foo', 'bar');
in the opened window.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.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,val ue);
}
</script>

and then just do
window.opener.a ddOption('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,val ue);
}
</script>

and then just do
window.opener.a ddOption('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
23658
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 before wanting to return the data to the launching page, and unfortunately in IE5 window.opener is undefined after the form is submitted, so i need some sort of workaround to make the page work in IE5. Thanks,
1
2253
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 using the window.opener property to reference the textbox. Everything works fine initially. However if the the main window does a postback and the calendar is re-opened, its window.opener property will always be null. So: BEFORE main window...
5
3722
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 controls are reinitialized but window.opener still refers to the original opener. I have simplified code than demonstrated the problem. This is the code for the base window which launches the dialog called Base.html:
1
16028
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" on the pop-up's form I want the pop-up to close & a new page to load in the "parent" window/page. I have this working in IE but cannot get it to work in Firefox. The parent window correctly loads the new page after submitting from the pop-up,...
19
31051
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(). The problem is that after the reload, it brings you right to the top of the page. When I click 'refresh" on the original page, it brings me back to the original viewing position. Is there a way to duplicate this in from the popup window. Also,...
2
2292
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 of different images that the user can select. When the user clicks "Submit", I'd like the image selection page to close and update the image on the originating page. To "play around" with this command until I can use it successfully, I wrote...
1
2650
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 using the window.opener property to reference the textbox. Everything works fine initially. However if the the main window does a postback and the calendar is re-opened, its window.opener property will always be null. So: BEFORE main window...
7
2857
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 to be set to null after the main page has excuted a postback. Can anyone explain this or at show that I'm wrong ? Is this a bug in IE ?
5
7528
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 click the attach it should upload file and close the window and send back control to Main page.. But it is not happening.. CODE: ========= <script LANGUAGE="JavaScript"> if ((window.opener != null) && (! window.opener.closed)) {
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.