Hi,
Problem :
I try to do so that, when a fragment is reached from an URI inside a document, an event with a defined function should be activated on the "targetted fragment".
The reason for context : The function will adjust the position of the targeted fragment :
note : the top of window is occupied by a sticky menu and the auto scroll (by navigator) into the document sets the "targeted fragment at the top of window then it is hidden by the menu
With CSS : when from a link a URI list
<a href="#fragment_id"> which points to <tag id="fragment_id">.....
a css defines : " #fragment_id:target { attribute... }" or .fragments_class:target { attributes...} will attrib attributes to current targeted #fragment_id.
This functions but the height of the top margin is not known, then JQ is the solution to make able to calculate the suitable position.
Tries
- $(".fragment_class:target").focus( function{....} /* or .scroll doesn't function */
- );
- $("document").scroll (function () {
- $(".fragment_class:target")....
- }); /* will be activated at each scroll but not only if the element is focused after a target, anyway can make the UI unusable with to much events */
Summary : I have not found any good solution to :
Activate a function on an element (a fragment), defined by a selector, when it is reached (focused) by the activation of a link to the fragment.
This is valid for internal or external defined URls or auto by navigator when a reload (chrome, at reload, will position - target - on the previous element id) is performed
Do somebody can help me
Best regards
Trebly