Problem with urls

I have a form on the page I'm working on, and (as if it werenโ€™t), if there is an error, I add the URL with

show?comments=2#track_1 

where comment = 2 bits is the feedback in which field went wrong, and track_1 is the identifier of the div in which my form is sitting. This works fine in IE (at least 8), but in firefox the page just sits at the top without going to the appropriate section.

Oddly enough, when I select the URL and press enter in the address bar (i.e. when I go to the address manually and not generated by the feedback form), it works in firefox!

Anyone have any ideas on what might happen?

EDIT

nb this only happens when javascript is off (although this is exactly when I need it to work!)

+4
source share
6 answers

Your problem sounds like a known bug. Confirm here .

+7
source

If you have autofocus on the page, this may be the cause of the problem. Try to remove autofocus and test.

If this is the case, move the error to mozilla via the link.

+1
source

Use the correct # -sign path, this is not by ID! You must indicate the position with the anchor as follows:

 <a name="track_1"></a> 
0
source

Add this to javascript to fix the view, change YOUR_ANCHOR, for the name of the anchor with the problems.

 $(document).ready(function (){ var anchor_id = window.location.hash; if (anchor_id != "#YOUR_ANCHOR") { var new_position = $(anchor_id).offset(); window.scrollTo(new_position.left,new_position.top); } }; 

This should reset the firefox problem.

0
source

If you use jQuery with smoothScroll, the following script located after all other javascript will work. You can check its operation in Firefox at http://cafedethaireno.net/index.php#togo_menu

 $(document).ready(function(){ var h = window.location.hash; if (h) { var headerH = $('#navigationMenu').outerHeight(); $('html, body').stop().animate({ scrollTop : $(h).offset().top - headerH + "px" }, 1200, 'easeInOutExpo'); event.preventDefault(); } }); 

Hope this helps, I use fixed header navigation to compensate for the top position, but the code can be easily manipulated.

0
source

For me, this problem was resolved by removing non-alphanumeric characters ( including spaces ), such as a double dot (also url encoded with url% 3A) using -_. like separators.

really not related to your problem, but maybe for others:

replace all spaces with a dash, an underscore or a period, then remove all alphanumeric characters and it should work.

0
source

Source: https://habr.com/ru/post/1345087/


All Articles