473,385 Members | 1,356 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,385 software developers and data experts.

window.opener Issue with Firefox

I already read about several problems using firefox and the
window.opener property. But obviously it didn't help out. So here is
my problem:

I got a "Search..." link which opens a new window with an FTP-browser.

function popup(url,width,height){
var popupX = (screen.width/2)-(width/2);
var popupY = (screen.height/2)-(height/2);
var pos = "left="+popupX+",top="+popupY;

winpops=window.open(url,"popup","width=" + width + ",height=" +
height + "," + pos + ",scrollbars=yes,toolbar=yes");
}

this code opens my popup. Now, the user browses his FTP and selects
some kind of folder or file. This value is automatically saved into a
readonly input form. To accept the selected path, the user got a form
button, which saves the path to the parent form (window.opener) and
closes the FTP-browser.

function acceptPathAndClose(path,formname,field) {
form_h = eval("opener." + formname + "." + field);
form_h.value = path;
self.close();
}

Firefox spams its JavaScript console with "opener.blabla got no
properties" and just does nothing. Internet Explorer executes this
code as expected. How can i solve this annoying problem?

Greets
Stefan
Jul 23 '05 #1
2 18383


Stefan Sch?rmeli wrote:

function acceptPathAndClose(path,formname,field) {
form_h = eval("opener." + formname + "." + field);
form_h.value = path;
self.close();
}

Firefox spams its JavaScript console with "opener.blabla got no
properties" and just does nothing.


You need to learn the proper way to address form elements:
windowObject.document.forms.formName
or
windowObject.document.forms['formName']
so in the above function you want
var form_h = opener.document.forms[formname].elements[field];
that way the form and the control are addressed properly in all browsers
starting from Netscape 3.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Martin Honnen wrote:
Stefan Sch?rmeli wrote:
function acceptPathAndClose(path,formname,field) {
form_h = eval("opener." + formname + "." + field);
form_h.value = path;
self.close();
}

Firefox spams its JavaScript console with "opener.blabla got no
properties" and just does nothing.


You need to learn the proper way to address form elements:
windowObject.document.forms.formName
or
windowObject.document.forms['formName']
so in the above function you want
var form_h = opener.document.forms[formname].elements[field];
that way the form and the control are addressed properly in all browsers
starting from Netscape 3.


Although

var form_h = opener.document.forms[formname].elements[field];

may fail in Internet Explorer if you attempt to do anything other than
access the form control's value. For example, if -field- is a <select> and
you attempt to add or remove(?) Option() objects from it via a new window,
you will not be able to.

For example:

var form_h = opener.document.forms[formname].elements[field];
form_h[form_h.length] = new Option(text, value);

would fail in Internet Explorer with "access denied". The way to achieve the
same result is with:

opener.someFunctionInOpener(formname, field, text, value);

Then in the opener window you'd have:

function someFunctionInOpener(fn, f, t, v) {
var form_h = document.forms[fn].elements[f];
form_h[form_h.length] = new Option(t, v);
}

Untested.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #3

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

Similar topics

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"...
1
by: humbads | last post by:
I am trying to get a popup window to work for editing notes in my application. Here's how I implemented it: The original frame is called ORIGINALFRAME and contains a link like this: <a...
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...
3
by: alison | last post by:
I am trying to redirect the parent page when the user clicks an html button in an aspx page by using the javascript: window.opener.location.href="EditOrders.aspx"; This works fine on IE for...
4
by: badaczewski | last post by:
The following javascript appears on a popup window. <script language="javascript" type="text/javascript"> function InsertContact(value) { window.opener.CallBackContact(value); window.close();...
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...
3
by: Asterix | last post by:
Hi Guys, I know this is probably an easy one, but I am having issues. Basically, I have a pop-up (child) that controls the parent window. Clicking on a link on the child window should redirect...
29
Frinavale
by: Frinavale | last post by:
I have 2 FireFox (version 2) browser windows opened. One is the child of the other. When the user is finished with the child window, a method in the parent window is called to refresh a...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.