473,503 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing objects from opened window

Hi,

I'm having problem accessing javascript-created elements from opened
window. This occurs only when I'm including another files in opened
window, javascript or css. When I comment out "<link>" and "<script>"
(point (0)), the script works fine.

The opening window itself (point (1)) can access the object. When page
has been loaded, then I can access the object also (point (3)). The
script does find included files (debug_test2.css and debug_test2.js), I
checked that.

Problem appears only on Firefox (my version is 1.5.0.6, on WinXP). On
IE (6.0) works also fine.
Anybody knows cure?
-------code start--------

<script type="text/javascript">

var win = window.open('about:blank', '_blank', '');

with (win.document) {
// (0) remove comments from next 2 rows,
//writeln('<link rel="stylesheet" href="debug_test2.css"
type="text/css" />');
//writeln('<scr'+'ipt type="text/javascript"
src="debug_test2.js"></scr'+'ipt>');
writeln('<table id="test"></table>');
writeln('<scr'+'ipt type="text/javascript">');
// (1) opened window itself has no problem accessing created table
writeln('document.writeln(document.getElementById( \'test\'));');
writeln('</scr'+'ipt>');
}

// (2) outputs NULL when 2 comments above (0) removed, otherwise has no
problems
document.writeln(win.document.getElementById('test ') + '<br>');

//-->
</script>

<!-- (3) after page has loaded, I can access the object -->
<input type="submit"
onclick="alert(win.document.getElementById('test') ); return false;">

-------code end--------

Sep 12 '06 #1
3 2096
ASM
kosmodisk a écrit :
Hi,

I'm having problem accessing javascript-created elements from opened
window. This occurs only when I'm including another files in opened
window, javascript or css. When I comment out "<link>" and "<script>"
(point (0)), the script works fine.
http://stephane.moriaux.perso.orange...i_clone_popup/
The opening window itself (point (1)) can access the object. When page
has been loaded, then I can access the object also (point (3)). The
script does find included files (debug_test2.css and debug_test2.js), I
checked that.

Problem appears only on Firefox (my version is 1.5.0.6, on WinXP). On
IE (6.0) works also fine.
Anybody knows cure?
something wrong in :
document.write(document.getElementById(\'test\'));
perhaps ?
<script type="text/javascript">

var win = window.open('about:blank', '_blank', '');
var win = window.open(); // will give same result

<script type="text/javascript">

var txt = '<link rel="stylesheet" href="debug_test2.css" '+
'type="text/css" />\n<script type="text/javascript" '+
'src="debug_test2.js"><\/script>\n'+
'<table id="test"><tr><td>a test<\/td><\/tr><\/table>\n'+
'<script type="text/javascript">\n'+
'document.write("\'"+document.getElementById(\'tes t\')+"\'");'+
'\n<\/script>';

// 1st test :
var win1 = window.open();
win1.document.writeln(txt);

// 2nd test :
var win2 = window.open();
win2.document.open();
win2.document.write('<html><body>\n'+txt+'\n<\/body><\/html>');
win2.document.close();

</script>

<form>
<input type="button" value="see 2"
onclick="alert(win2.document.getElementById('test' ));win2.focus();">
<input type="button" value="see 1"
onclick="alert(win1.document.getElementById('test' ));win1.focus();
return false;">
</form>
<!-- (3) after page has loaded, I can access the object -->
<input type="submit"
<input type="button"


--
Stephane Moriaux et son [moins] vieux Mac
Sep 12 '06 #2
Hi,
something wrong in :
document.write(document.getElementById(\'test\'));
perhaps ?
No, this place works fine. This wasn't the problem in the first place.
I checked the link you gave, and I don't think it had any use to me :P
(can't speak any French either :)

I'll explain again:
* javascript code opens new window, and outputs this HTML into this
window:
<link rel="stylesheet" href="debug_test2.css" type="text/css" />
<script type="text/javascript" src="debug_test2.js"></script>
<table id="test"></table>

* now, when i try to access this object from OPENER window ON THE SAME
REQUEST (which means I dont run this code by pushing button or similar)
alert(win.document.getElementById('test'));
// this returns NULL on Firefox.

* when I comment out <linkand <scriptlines from output HTML, my FF
gets the object.
alert(win.document.getElementById('test'));
// now it returns HTMLObject or something

Kosmodisk
ASM wrote:
kosmodisk a écrit :
Hi,

I'm having problem accessing javascript-created elements from opened
window. This occurs only when I'm including another files in opened
window, javascript or css. When I comment out "<link>" and "<script>"
(point (0)), the script works fine.

http://stephane.moriaux.perso.orange...i_clone_popup/
The opening window itself (point (1)) can access the object. When page
has been loaded, then I can access the object also (point (3)). The
script does find included files (debug_test2.css and debug_test2.js), I
checked that.

Problem appears only on Firefox (my version is 1.5.0.6, on WinXP). On
IE (6.0) works also fine.
Anybody knows cure?

something wrong in :
document.write(document.getElementById(\'test\'));
perhaps ?
<script type="text/javascript">

var win = window.open('about:blank', '_blank', '');

var win = window.open(); // will give same result

<script type="text/javascript">

var txt = '<link rel="stylesheet" href="debug_test2.css" '+
'type="text/css" />\n<script type="text/javascript" '+
'src="debug_test2.js"><\/script>\n'+
'<table id="test"><tr><td>a test<\/td><\/tr><\/table>\n'+
'<script type="text/javascript">\n'+
'document.write("\'"+document.getElementById(\'tes t\')+"\'");'+
'\n<\/script>';

// 1st test :
var win1 = window.open();
win1.document.writeln(txt);

// 2nd test :
var win2 = window.open();
win2.document.open();
win2.document.write('<html><body>\n'+txt+'\n<\/body><\/html>');
win2.document.close();

</script>

<form>
<input type="button" value="see 2"
onclick="alert(win2.document.getElementById('test' ));win2.focus();">
<input type="button" value="see 1"
onclick="alert(win1.document.getElementById('test' ));win1.focus();
return false;">
</form>
<!-- (3) after page has loaded, I can access the object -->
<input type="submit"

<input type="button"


--
Stephane Moriaux et son [moins] vieux Mac
Sep 18 '06 #3
ASM
kosmodisk a écrit :
Hi,
>something wrong in :
document.write(document.getElementById(\'test\'));
perhaps ?
No, this place works fine. This wasn't the problem in the first place.
I checked the link you gave, and I don't think it had any use to me :P
(can't speak any French either :)
Dommage :-)
I'll explain again:
I understand anything what you mean.
You want to acces to table 'test' in your popup 1 (win1)
while you're calling from popup 2 (win2)
using the opener of this popup 1 ?

if your alert is calling 'win2' form 'win1' :
alert(opener.win2.document.getElementById('test'). tagName);

if your alert is calling 'win1' form 'win2' :
alert(opener.win1.document.getElementById('test'). tagName);

http://stephane.moriaux.perso.orange...popup_oui_non/
I think there is no need to speak french here (*)

or have a look what I understood you want
http://stephane.moriaux.perso.orange.../table-opener/

(*) dictionary
ouvrir = to open ouvert = opened
fermer = to close fermé = closed
dis-moi = tell me

--
ASM
Sep 26 '06 #4

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

Similar topics

6
2981
by: Mica Cooper | last post by:
Hi, I have a series of Select menus on a page. I am trying to allow the user to click on the Select title and have it popup a help window. This works fine with the following code except that all...
3
2015
by: datactrl | last post by:
Hi, all Is that possible I can assign an window object variable to an already opened window? With window.open(), we can get a window object from opened window. If a window has already opened, is...
10
3049
by: soup_or_power | last post by:
The pop up window has several checkboxes. I'm unable to access the checkboxes using the handle from window.open. Any way to do this? var display; function showSugg(but_id, sugg1, sugg2, sugg3,...
1
2579
by: adamredwards | last post by:
I have a page with some form elements that are dynamically generated. They are inserted into the dom by first cloning a node, changing the values like name, and then inserted with insertBefore(). ...
4
3598
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if...
2
1392
by: ctrl.undo | last post by:
Hi, I'm not sure if this is possible, but I'm looking for a way to access another IE browser window using JavaScript (assuming the two browser windows are running in the same instance). The...
2
2743
by: Sal | last post by:
I wonder if anyone has had problems with the above recently and has managed to solve them. I have opened a new window using window.open which performs as would be expected in both IE and Firefox,...
5
3619
by: Jonathan Boivin | last post by:
Hi, I've got some problems with loading bills using a bill usercontrol I built. If I load all current bills in my test environment (156) everything is fine once, but repeating the operation...
0
964
by: rajeshskollam | last post by:
Dear All, I have stuck in a problem that i want to get the handle of crrently opened windows in our system.My application is that a virtual key board,if i open a notepad or word docs after that i...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
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,...
0
7353
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...
1
7011
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...
0
7468
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...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.