ابحث في الدعم

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.

Learn More

Why Firefox always jumps to start of page after opening another page in the same window and getting back?

  • 11 ردًا
  • 2 have this problem
  • 2 views
  • آخر ردّ كتبه aspis

more options

Re: Firefox 57 (Quantum)

I try to use two classic JavaScript methods of opening a URL: 1) window.location = URL 2) window.open(URL} After executing one of these commands, FF opens the URL, OK, but when I return to the previous page (with Backspace or, "Back" arrow), FF always jumps at the top of the page, whereas the page had been scrolled down. In fact, I can see for a fraction of a second the FF already jumps at the top of the page instantly after clicking on the link (i.e. before even bringing up the new URL)!

Note that Internet Explorer behaves as expected, i.e. it keeps the last position where the link was clicked on, with the same HTML file! So it is definitely a FF bug. Can it be repaired?

Re: Firefox 57 (Quantum) I try to use two classic JavaScript methods of opening a URL: 1) window.location = URL 2) window.open(URL} After executing one of these commands, FF opens the URL, OK, but when I return to the previous page (with Backspace or, "Back" arrow), FF always jumps at the top of the page, whereas the page had been scrolled down. In fact, I can see for a fraction of a second the FF already jumps at the top of the page instantly after clicking on the link (i.e. before even bringing up the new URL)! Note that Internet Explorer behaves as expected, i.e. it keeps the last position where the link was clicked on, with the same HTML file! So it is definitely a FF bug. Can it be repaired?
Attached screenshots

All Replies (11)

more options

Hello, to file a bug report - head on over to https://bugzilla.mozilla.org and create an account - Once registered follow the documentation for bug filing to get started.

more options

This can happen when the website instructs Firefox not to cache the page. When this happens then Firefox won't be able to return to the previous position. Best in such cases is to open other pages in a new tab (middle-click or via the right-click context menu). Then you can close the tab to return to the original page.

more options

What website, cache and all that stuff ? Didn't you read my description? Please do next time. It's a simple HTML file. I also included a screenshot. And no, opening the links to a new TAB is far from a solution! Imagine what a pain this is if you check a list of a lot of links. Again, see the screenshot I included; I didn't do that for nothing. Think also of checking links in Google results!

more options

Is this a new issue in Firefox 57 that you didn't notice in Firefox 56?

What is your code? If you are attaching it to a link, make sure to cancel the default action of the link:

POTENTIALLY PROBLEMATIC:

<a href="#" onclick="window.open('someurl.html');">

SAFER:

<a href="#" onclick="window.open('someurl.html'); return false;">

more options

Yes, this works. But then, one has to write the whole absolute address for each link, so what's the use? There's no need for a JS script then. The JS script helps exactly to avoid writing the same base URL stupidly hundreds of times!

Modified by aspis

more options

I think a long time ago it used to work in the script, but it's difficult to remember. Maybe it works in the script if you target window.open() to a new window or named window, but not the same tab? I can't recall testing that recently.

There are always little optimizations being made to the code that don't make the release notes.

Go ahead and search for or file a new bug if Firefox is inconsistent.

https://bugzilla.mozilla.org/

more options

I have modified my reply, sorry. Please read what I realized your suggestion involves, even if it solves the "jumping-to-the-top" problem. Thanks anyway!

more options

I don't understand your edited reply. Where is your test page demonstrating this problem? Please give a link.

more options

How to explain better? Well, you suggest doing the following:

      <a href="#" onclick="window.open('someurl.html'); return false;">

Right? Well, if 'someurl.html' contains an absolute base ref (e.g. https://support.mozilla.org/en-US/questions/ plus the page name, '1192073') and I have to create 1000 such links (with the same absolute base ref) I could well use directly

     <a href="someurl.html">

That's why I am asking, what's the use? A JavaScript in this case serves to automatically add the absolute base ref to the page name, so that you don't have to write it in each href. This is a very common practice used e.g. in loading images from a common path. Is it clear now?

more options

I understand my example. What I don't understand is what's going wrong on your page. Can you post a link to a page demonstrating the problem? If you plan to file a bug, you will want to provide a minimal test case demonstrating which links works and which don't to show that Firefox is inconsistent. Might as well give me the link now.

more options

What link??? It's a simple, local HTML file. Besides, I have attached screenshots (compiled into a single image).