Søg i Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Læs mere

This code works in Chrome. How can I make it work in FF as well.

  • 7 svar
  • 3 har dette problem
  • 6 visninger
  • Seneste svar af cor-el

more options

function openWin(ID) { // open workshop ID in another window

   var URL = '/chatroom.php?ID='+ID;
   var name = 'Chat'+ID;   // so if you open it twice it reopens the window.
   var win = window.open(,name); // no URL - won't refresh

   if (win.location == "about:blank") { // new open
       win.location.href = URL; 
   } 
   win.focus();

}

This code is called on a "javascript link". The first call is to open the new window and switch to it. Any subsequent call is to reopen the window WITHOUT REFRESHING and switch to it.

As mentioned. The code works perfectly in Chrome. In Firefax 23.01 the focus call is ignored, leaving the background window or tab in the background.

For what its worth, it does the same in IE 10 either, but IE is a lost cause.

function openWin(ID) { // open workshop ID in another window var URL = '/chatroom.php?ID='+ID; var name = 'Chat'+ID; // so if you open it twice it reopens the window. var win = window.open('',name); // no URL - won't refresh if (win.location == "about:blank") { // new open win.location.href = URL; } win.focus(); } This code is called on a "javascript link". The first call is to open the new window and switch to it. Any subsequent call is to reopen the window WITHOUT REFRESHING and switch to it. As mentioned. The code works perfectly in Chrome. In Firefax 23.01 the focus call is ignored, leaving the background window or tab in the background. For what its worth, it does the same in IE 10 either, but IE is a lost cause.

Alle svar (7)

more options

Hi,

Leave feedback for Firefox developers, you can go to the Firefox Help menu and select Submit Feedback... or use this link. (You'll need to be on the latest version of Firefox to submit feedback). Your feedback gets collected at http://input.mozilla.org/, where a team of people read it and gather data about the most common issues.

We will get back to you ! Report if this helped ! Thanks!

more options

By default, scripts in pages are not allowed to change the window focus. The internal preference for this is named dom.disable_window_flip. Users can manually enable this capability for scripts (see: https://support.mozilla.org/en-US/que.../967108#answer-464407), but I suspect that few will do so.

You might not have noticed this before because you might have changed this preference a long time ago using the Advanced JavaScript settings dialog. When Firefox 23 removed that dialog, I think the settings in that dialog were reset to their default values.

more options

What is the value of the dom.disable_window_flip pref on the about:config page?

more options

dom.disable_window_flip has the default value of true.

Changing it to false does not alter the behavior of the routine.

Ændret af hobson42 den

more options

I tested using a bookmarklet: *

javascript:var winTest = window.open("", "winTest1", "width=800,height=600"); winTest.focus(); if(winTest.location.href == "about:blank") winTest.location.href = "http://support.mozilla.org/"; void 0;

Note that I've switched the order of the statements so that winTest.focus() precedes accessing the location object.

When I am viewing a page on this site, the window opens as expected. If I switch focus back to my original window and run the bookmarklet again:

  • with dom.disable_window_flip set to its default value of true, the focus does not change correction: this does seem to work
  • with dom.disable_window_flip set to false, the focus does change

If I try the same bookmarklet from another site, I get a permission error (cross-domain violation) in the Browser Console (Ctrl+Shift+j) attempting to check the current href on the second run. This halted the script before it could change focus. That's why I switched the sequence of statements.

Can you replicate that?

* To create a bookmarklet, display the Bookmarks Toolbar, then copy the above string of code. Right-click the Bookmarks Toolbar, choose New Bookmark, paste the code into the Location box and choose any name you like.

Ændret af jscher2000 - Support Volunteer den

more options

My results are the same - it works whatever the value of dom.disable_window_flip is.

The first click, opens the window and loads it, and the pop-up becomes the front window.

The second click (on the back window) finds the pop-up, brings it to the front, and it does not refresh.

I modified the code in my function, and it still appears to ignore the focus() whatever the value of dom.disable_window_flip

BTW - my users can't or would be reluctant to change their configs, so I really need a solution that works with the default.

more options

A good place to ask advice about web development is at the mozillaZine "Web Development/Standards Evangelism" forum.

The helpers at that forum are more knowledgeable about web development issues.
You need to register at the mozillaZine forum site in order to post at that forum.