Link to home
Start Free TrialLog in
Avatar of Mark
Mark

asked on

Prevent Firefox page from going to the background when clicking a spreadsheet link

I have the html code shown below. In Firefox, when I click the link to open the spreadsheet, it puts the current window (having the link) into the background. This is quite inconvenient as the user must click on the Firefox icon(s) in the taskbar to find their page when done with the spreadsheet. IE does not send the page to the background.

Note that this page is opened using
window.open('thisProgram.jsp','_blank','scrollbars=1,resizable=1,width=700,height=400,top=0')

Open in new window

and does not have a tab among the other Firefox tabs. Therefore, the user doesn't even have a tab to click on to get their page back to the foreground (nor is there a tab in IE).
<div>
  <a href="tmp/calcFAS701.csv" target="_blank">
  <img alt="" style="vertical-align: middle; border:0" width="16" src="images/Excel.jpg">
  &nbsp;get spreadsheet</a>
</div>

Open in new window

Instead of the above, I tried:

<span onclick="w=window.self;w1=window.open('tmp/mySpreadsheet.csv','_blank');w.focus()">click me</span>

but that ended up bringing into focus some apparently random page in the tab-list.

Is there a way to prevent this page from disappearing into the background when the spreadsheet link is clicked?
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

I'm not having that problem on any of my pop-ups in any browser.  There may be something missing from your code.  I'm pretty sure that 'top=0' is not valid in Firefox.  I believe the top-most pixel is 1, not 0.  Try this demo from W3Schools.

http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_open5
Avatar of Mark
Mark

ASKER

You may be right on the top=0 thing, but that's not where I'm having the issue. The page containing the link does display, even if the 'top' parameter is wrong. It's the behavior when the spreadsheet link on that page is clicked.

So, maybe a bit of clarification ... I have a page we'll call "daddy". "daddy" contains a window.open() function (which has the 'top' parameter).

When the user clicks the button on "daddy" to trigger the window.open(), a new window, let's call it "boy" is opened. On "boy" is a link referencing a spreadsheet. When the user click the spreadsheet link on "boy" yet another new window opens which has the spreadsheet.

This all works as expected except when the spreadsheet link is clicked, "boy" disappears into the background. That's the problem I'm trying to solve, not the relative placement of "boy" via the 'top' parameter.
A pop-up in a pop-up?  You need to show us a demo that displays the problem.
I've put up a quick and simple demo of what I think you're trying to do here:  http://www.yamiam.net/yamiam/JSNewWin/JSNewWindowOne.html
I think the issue here is that you're comparing IE behavior to Firefox behavior when clicking a link to open a spreadsheet. The first problem is that you cannot compare IE behavior to any other browser as IE lives on and in another complete realm of reasoning.

Is IE actually opening the spreadsheet in a browser window or tab? Since IE and Excel are both Microsoft applications as is likely the Windows operating system, it is not unexpected that IE could open the spreadsheet in a browser window. Firefox, on the other hand, is not a Microsoft product and must hand off the spreadsheet to the appropriate application for viewing it, more than likely Excel, which would take the focus of the operating system away from Firefox. Does this accurately describe the situation you're encountering?
Avatar of Mark

ASKER

Kim Walker: Both IE and Firefox open the spreadsheets in Excel. The difference is that with Firefox, the page containing the spreadsheet link disappears into the background while that does not happen with IE. Even though IE sucks in many ways, it does have the desired behavior in this case. Check out Dave Baldwin's demo.

Dave Baldwin: Yes, your demo exactly shows the problem. Your "JS New Windows 2" disappears into the background when the spreadsheet link on that page is clicked. To get back to it I have to hunt for it in my taskbar. You'll also notice that no tab is created for it in the tablist of other FireFox pages. If you try your demo with IE, it works as expected. The spreadsheet is opened and the "JS New Windows 2" remains visible.
I'm getting the same behavior in both. The only difference is that JS New Wndow 2 is in the top left corner in IE. It's centered horizontally near the top of the screen in Firefox.

IE 11:
User generated image
Firefox 46.0.1:
User generated image
Avatar of Mark

ASKER

That's interesting. So, it's doable with Firefox. Perhaps a setting of some kind? Here's my screenshot with Dave's "Window 2" opened:
User generated imageAnd after clicking on the spreadsheet link (I've moved it off to the side to show the Window Two is not underneath):User generated imageI'm using Firefox 45.0.2. I'll update and see if that makes any difference.
I'm getting the same behavior as Kim is in Firefox on XP and in Firefox and IE11 on Windows 7.  I get similar behavior as you do using Chrome on Win 7 but all have to do is hover over the Chrome icon to see the separate pages.
User generated image
I have modified my demo page.  You can open Page Two in the original small window or you can open it in a full page.  When you open it in a full page, it does not disappear.  Apparently the minimized pop-up window is the problem.  The full page version works in Chrome also.
Avatar of Mark

ASKER

My behavior does not change with Firefox 46.0.1.

dave Baldwin:
Apparently the minimized pop-up window is the problem.
Yes, not a problem with full page. However, I need a page as shown in your 1st demo.

So, if you (Dave) and Kim do not show this disappearing window phenomenon in Firefox on WIN7, and I do, then it must have something to do with settings, right? Any idea what settings I could change? Nothing jumps out at me.
SOLUTION
Avatar of Kim Walker
Kim Walker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark

ASKER

Kim Walker: my Firefox settings  are the same as yours. Testing with Firefox  on Ubuntu  does NOT cause the 2nd smaller window  to get pushed to the background.  This only happens  for me with Firefox on WIN7.

So, I guess I just have to live with this, eh? Any other ideas?
It was happening for me in Chrome on both XP and Win 7.  Opera 36 seems to work alright though.
Firefox on CentOS 6.7  hides page two when I click on the spreadsheet link.  However... if I cancel the spreadsheet download, page two re-appears!
Avatar of Mark

ASKER

OK thanks. Too bad the problem can't be solved on my office workstations :(