How to open a new window in Firefox and keep the reference?

D

deBaer

Hi!

For an in-house web application (it will only be deployed on Firefox
browsers with JavaScript turned on), I need to open a preview window
(which needs to be a separate window, even if Firefox is set to open
targeted links in new tabs) and be able to change the preview window's
location.href from the opening window, even after a new page is loaded
into that window.

Is there any way to do that?

Thanks a lot,

Simon
 
E

Erwin Moller

Hi!

For an in-house web application (it will only be deployed on Firefox
browsers with JavaScript turned on), I need to open a preview window
(which needs to be a separate window, even if Firefox is set to open
targeted links in new tabs) and be able to change the preview window's
location.href from the opening window, even after a new page is loaded
into that window.

Is there any way to do that?

Thanks a lot,

Simon

Hi Simon.

window.open() returns a reference.
You can use that reference to find the window and change its location
property.

Regards,
Erwin Moller
 
D

deBaer

Hi!

window.open() returns a reference.
You can use that reference to find the window and change its location
property.

Yeah, thanks, but this solution doesn't address two of my problems:
Since most people have set their browser to open new windows in a new
tab instead, this doesn't make a new window. And the reference
returned is lost as soon as the user clicks on a link in the original
window, causing it to load a new page.

All the pages I found when researching show the window.open method and
the target="whatever" method, are those two the only ways to open a
new window?

Simon
 
M

Martin Honnen

For an in-house web application (it will only be deployed on Firefox
browsers with JavaScript turned on), I need to open a preview window
(which needs to be a separate window, even if Firefox is set to open
targeted links in new tabs) and be able to change the preview window's
location.href from the opening window, even after a new page is loaded
into that window.

Is there any way to do that?

It should be possible if you write a Firefox extension and your users
install that I think. I don't think you have a chance with unprivileged
script simply loaded from your web server.
 
A

ASM

En réponse à (e-mail address removed) qui écrivit, en date du : 3/09/07 16:30,
le message suivant :
Hi!

For an in-house web application (it will only be deployed on Firefox
browsers with JavaScript turned on), I need to open a preview window
(which needs to be a separate window, even if Firefox is set to open
targeted links in new tabs)

In that case, with window.open() , my Firefox always open a popup.
and be able to change the preview window's
location.href from the opening window, even after a new page is loaded
into that window.

Is there any way to do that?

<script type="text/javascript">
function pop(myFile) {
// opening popup after a small time (if not yet opened)
setTimeout( function() {
if(typeof(truc)=='undefined' || truc.closed)
truc = window.open('','myTarget','width=300,height=300');
// to regulary set back to main (mother) window the reference of popup
truc.onload = function() {
setInterval(function() { opener.truc = self; }, 200);
}
truc.location = myFile;
truc.focus();
},
200);
return false;
}
</script>

Tested in Fx 2.0.0.6
 
T

Thomas 'PointedEars' Lahn

For an in-house web application (it will only be deployed on Firefox
browsers with JavaScript turned on), I need to open a preview window
(which needs to be a separate window, even if Firefox is set to open
targeted links in new tabs) and be able to change the preview window's
location.href from the opening window, even after a new page is loaded
into that window.

Is there any way to do that?

There are at least two. One is implicit. If you give your new Window
object a name, you will be able to load any other document into it as long
as you use that name:

window.open("foo", "myPreview", "...");
...
window.open("bar", "myPreview", "...");

It would be wise here to write a wrapper function that only gets the URI of
the document to load as argument.

The other way is explicit, by using only the `location' property of the
Window object, not `location.href'. The former is defined in Netscape
JavaScript since version 1.0 (the so-called "DOM Level 0") and the Gecko
DOM, and implemented in Firefox not to be subject to the Same Origin Policy:

var w = window.open("http://www.google.com/", "...", "...");
...
w.location = "http://localhost/";

Tested in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6)
Gecko/20070725 Firefox/2.0.0.6

However, both ways do not work for file:// URIs. It is not clear what
exactly you mean by "page" so either of those may suffice. If not, you
should write a Firefox extension or a Gecko-based application, indeed.


HTH

PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top