By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,644 Members | 2,423 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,644 IT Pros & Developers. It's quick & easy.

Using DOM to access other windows

P: n/a
All,

Is there any way to access a separate IE 6.0 browser process via the
Javascript DOM ? For example, open IE once. Open IE again (not using
File->New). Can the second IE browser/process access the DOM objects
of the first, if so, can someone please post a bit of sample code?

thanks.
-Jeff
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
je******@hotmail.com (Jeff T.) writes:
Is there any way to access a separate IE 6.0 browser process via the
Javascript DOM ?


Not directly.
One thing to notice, is that different IE windows are all using the
same browser component, so they can theoretically communicate.

To access another window's properties, you need a reference to that
window. There is no direct way to find such a reference to an existing
window.

There is a (not so pretty) hack.
If you open a new window with a name, i.e.,
var w = window.open("","windowName");
in both browsers, then the second to call window.open will get a reference
to the window openend by the first.
If the first browser stores a reference to itself in the window, the
second can read it.

Try this:

In browser 1:
var w = window.open("","foobarbaz");
w.dummy = window;

In browser 2:
var w = window.open("","foobarbaz");
otherBrowser = w.dummy;
otherBrowser.otherBrowser = window;
w.close();

After this, both browser windows have a reference to the window object
of the other browser. Try it by, e.g., changing the background:

In browser 1:
otherBrowser.document.body.style.backgroundColor = "red";

In browser 2:
otherBrowser.document.body.style.backgroundColor = "green";

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
DU
Jeff T. wrote:
All,

Is there any way to access a separate IE 6.0 browser process via the
Javascript DOM ? For example, open IE once. Open IE again (not using
File->New). Can the second IE browser/process access the DOM objects
of the first,
No. It's possible only and only if the "second" browser window was
opened via javascript. Only in cases where the "second" window is a
sub-window (also referred as secondary window or child window) created
with the window.open() call.

if so, can someone please post a bit of sample code?
thanks.
-Jeff


Open a sub-window and dynamically DOM-insert an image:
http://www10.brinkster.com/doctorunc...geInPopup.html

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #3

P: n/a
Hello Lasse,

This worked wonders! Thank you for this piece of ingenious advice.

Regards,
-Jeff
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<is**********@hotpop.com>...
je******@hotmail.com (Jeff T.) writes:
Is there any way to access a separate IE 6.0 browser process via the
Javascript DOM ?


Not directly.
One thing to notice, is that different IE windows are all using the
same browser component, so they can theoretically communicate.

To access another window's properties, you need a reference to that
window. There is no direct way to find such a reference to an existing
window.

There is a (not so pretty) hack.
If you open a new window with a name, i.e.,
var w = window.open("","windowName");
in both browsers, then the second to call window.open will get a reference
to the window openend by the first.
If the first browser stores a reference to itself in the window, the
second can read it.

Try this:

In browser 1:
var w = window.open("","foobarbaz");
w.dummy = window;

In browser 2:
var w = window.open("","foobarbaz");
otherBrowser = w.dummy;
otherBrowser.otherBrowser = window;
w.close();

After this, both browser windows have a reference to the window object
of the other browser. Try it by, e.g., changing the background:

In browser 1:
otherBrowser.document.body.style.backgroundColor = "red";

In browser 2:
otherBrowser.document.body.style.backgroundColor = "green";

/L

Jul 20 '05 #4

P: n/a
Hi again,

The two pages talk perfectly if they're both local html files.
However, when I run Tomcat (a web server) on one of the pages, and the
other page is local, I'm getting permission denied on an attempt to
get the third dummy window.

The JavaScript error is as follows:
Error: Permission Denied
on the line:
otherBrowser = w.dummy;

Any advice? Thanks.
-Jeff
je******@hotmail.com (Jeff T.) wrote in message news:<1b**************************@posting.google. com>...
Hello Lasse,

This worked wonders! Thank you for this piece of ingenious advice.

Regards,
-Jeff
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<is**********@hotpop.com>...
je******@hotmail.com (Jeff T.) writes:
Is there any way to access a separate IE 6.0 browser process via the
Javascript DOM ?


Not directly.
One thing to notice, is that different IE windows are all using the
same browser component, so they can theoretically communicate.

To access another window's properties, you need a reference to that
window. There is no direct way to find such a reference to an existing
window.

There is a (not so pretty) hack.
If you open a new window with a name, i.e.,
var w = window.open("","windowName");
in both browsers, then the second to call window.open will get a reference
to the window openend by the first.
If the first browser stores a reference to itself in the window, the
second can read it.

Try this:

In browser 1:
var w = window.open("","foobarbaz");
w.dummy = window;

In browser 2:
var w = window.open("","foobarbaz");
otherBrowser = w.dummy;
otherBrowser.otherBrowser = window;
w.close();

After this, both browser windows have a reference to the window object
of the other browser. Try it by, e.g., changing the background:

In browser 1:
otherBrowser.document.body.style.backgroundColor = "red";

In browser 2:
otherBrowser.document.body.style.backgroundColor = "green";

/L

Jul 20 '05 #5

P: n/a
je******@hotmail.com (Jeff T.) writes:
The two pages talk perfectly if they're both local html files.
However, when I run Tomcat (a web server) on one of the pages, and the
other page is local, I'm getting permission denied on an attempt to
get the third dummy window.
Yes, the dummy window belongs to the domain of the page that opened it
until a page is loaded into it. Cross domain scripting restrictions apply.
Any advice?


If one of the pages are always local, and you are using Internet
Explorer, you can make it an HTA-file (HTML application, look it up on
MSDN). That gives it permission to ignore cross domain restrictions.
You will just have to make the other page open the window.

If you want to have it work generally, i.e., on other people's
browsers, across domains, then my advice is to give up. Any cross
domain scripting hole you find will be closed eventually, and
most people will not change their default security settings to
accomodate your page.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6

P: n/a
I tried the HTA lead you gave me, and it proved successful, and
sufficient for my needs. Thank you very much, Lasse.

Regards,
-Jeff
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<4q**********@hotpop.com>...
je******@hotmail.com (Jeff T.) writes:
The two pages talk perfectly if they're both local html files.
However, when I run Tomcat (a web server) on one of the pages, and the
other page is local, I'm getting permission denied on an attempt to
get the third dummy window.


Yes, the dummy window belongs to the domain of the page that opened it
until a page is loaded into it. Cross domain scripting restrictions apply.
Any advice?


If one of the pages are always local, and you are using Internet
Explorer, you can make it an HTA-file (HTML application, look it up on
MSDN). That gives it permission to ignore cross domain restrictions.
You will just have to make the other page open the window.

If you want to have it work generally, i.e., on other people's
browsers, across domains, then my advice is to give up. Any cross
domain scripting hole you find will be closed eventually, and
most people will not change their default security settings to
accomodate your page.

/L

Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.