• Gear
  • Shots
  • Photo Craft
  • Video
  • Wide Angle
  • Support
  • New Stuff
  • More
Support SmugMug Support Bug Reporting Links to Named Anchors

FAQtoid

Ever wanted to create an Avatar? Creating an Avatar!

Searching Dgrin with Google Searching with Google

Dgrin Challenges

Congratulations to the Winner of DSS #130 (Hot or Cold), Memol..

The next Dgrin Challenge DSS #131 (Music) is open for entries through June 24th, 2013 at 8:00pm PDT.

As always, we look forward to your participation but please do take a moment to read through the rules before posting your entry.

Past DSS Challenge Winners, DSS Challenge Rules, and other important DSS Challenge information is here.

Need some help with Accessories?

Tutorials

Ever find yourself wondering just how someone managed to create an image using different effects?

Here are three simple tutorials we hope will encourage you to try something new.

The Hot Seat

A lifelong interest in landscape photography has led Eyal Oren to make a study of his adopted hometown of Marblehead, MA. As you can see, his dedication is paying off!

Africa!

Dgrinners Harryb, Pathfinder, and others joined Andy Williams and Marc Muench on Safari in East Africa recently. Here are some awesome threads to check out!

 
Thread Tools Display Modes
Old Aug-16-2009, 10:52 AM
#1
Tinkersdamn is offline Tinkersdamn OP
Big grins
Links to Named Anchors
Links to named anchors inside of resources at SmugMug do not work properly.

The URI's appear to be mangled by SmugMug. The result is that, in situtations where the to/from link anchors are on different pages, the page returned is always positioned at the top, instead of at the location in the target page specified by the fragement identifier.

For example; href="/gallery/foo#bar" should return a resource "foo" and preserve the fragment identifier "#bar" in the URI so that the browser can position its view to the proper point inside of the resource.)

This works properly in SmugMug only when both the 'to' and 'from' anchors are in the same page (it still mangles the URI) but not if the pages are different.


Details, examples and plenty of discussion of this behavior is here at this thread.

This is a link to the w3c specification which describes how fragment identifiers should work. The link itself is also an excellent example of the proper behavior.

I've managed to use a less than perfect workaround so this is not urgent. Just wanted to get it logged as a bug. Thanks.

Last edited by Tinkersdamn; Aug-16-2009 at 12:28 PM.
Old Aug-18-2009, 07:49 PM
#2
{JT} is offline {JT}
Code Monkey
{JT}'s Avatar
Do you have an example page to your work around? I recently fixed a bug with the SmugMug viewing style where a gallery would not load if you sent a link with a hash tag that we did not expect (we look for ImageID, Page # or Lightbox).

However, if you are referring to a non-gallery page, then you are probably out of luck

Quote:
Originally Posted by Tinkersdamn
Links to named anchors inside of resources at SmugMug do not work properly.

The URI's appear to be mangled by SmugMug. The result is that, in situtations where the to/from link anchors are on different pages, the page returned is always positioned at the top, instead of at the location in the target page specified by the fragement identifier.

For example; href="/gallery/foo#bar" should return a resource "foo" and preserve the fragment identifier "#bar" in the URI so that the browser can position its view to the proper point inside of the resource.)

This works properly in SmugMug only when both the 'to' and 'from' anchors are in the same page (it still mangles the URI) but not if the pages are different.


Details, examples and plenty of discussion of this behavior is here at this thread.

This is a link to the w3c specification which describes how fragment identifiers should work. The link itself is also an excellent example of the proper behavior.

I've managed to use a less than perfect workaround so this is not urgent. Just wanted to get it logged as a bug. Thanks.
Old Aug-19-2009, 07:22 AM
#3
Tinkersdamn is offline Tinkersdamn OP
Big grins
Quote:
Originally Posted by {JT}
Do you have an example page to your work around? I recently fixed a bug with the SmugMug viewing style where a gallery would not load if you sent a link with a hash tag that we did not expect (we look for ImageID, Page # or Lightbox).

However, if you are referring to a non-gallery page, then you are probably out of luck
The site reference is above. But... mine is a practical workaround not a technical one. It is simply to point the user to the page with the content and place an unordered list at the top of the page that can be used to navigate to the intended target anchor. Since things seem to work properly inside of a page this is a workable solution albeit more complicated for users than it should be.

The code that parses the URI inside SmugMug needs to be changed to preserve the fragment identifier '#foo' in all cases and tack it back onto the URI that is returned to the browser. This is beyond my mere mortal capabilities.

I can only speculate that the original design intended to use the '#' correctly, and the fragment identifiers pointed to photos inside of gallery pages and that these locations were marked with anchors. But then someone got creative and bent the design so that the '#' was assumed to point to a pre-ordained set of anticipated objects which of course left the W3C standards in the dust. Just a hunch...
Old Aug-19-2009, 08:52 AM
#4
{JT} is offline {JT}
Code Monkey
{JT}'s Avatar
I don't want to get in to how we develop the site too much here, but we do use redirects to build certain pages. For example, we don't have a million folders inside of the /gallery/ url that contain all of the albums for the site :)

Your problem has actually been my problem as well, since I would love to build a page using the fragment identifier without invoking javascript. What I found out is that the browser does not send the fragment identifier or hash tag to the server when it requests a web page. The browser only sends the important part of the URL - but keeps that hash tag for itself to use. (Some browsers MAY send the fragment identifier - but certainly not the majority of them).

The only work around I know is to have a little bit of javascript at the top of your page that looks for location.hash and reloads it if it finds anything (after the page loads).

I hope that makes sense, if not just let me know and I can try again :)


Quote:
Originally Posted by Tinkersdamn
The site reference is above. But... mine is a practical workaround not a technical one. It is simply to point the user to the page with the content and place an unordered list at the top of the page that can be used to navigate to the intended target anchor. Since things seem to work properly inside of a page this is a workable solution albeit more complicated for users than it should be.

The code that parses the URI inside SmugMug needs to be changed to preserve the fragment identifier '#foo' in all cases and tack it back onto the URI that is returned to the browser. This is beyond my mere mortal capabilities.

I can only speculate that the original design intended to use the '#' correctly, and the fragment identifiers pointed to photos inside of gallery pages and that these locations were marked with anchors. But then someone got creative and bent the design so that the '#' was assumed to point to a pre-ordained set of anticipated objects which of course left the W3C standards in the dust. Just a hunch...
Old Aug-19-2009, 08:54 AM
#5
jfriend is online now jfriend
Scripting dude-volunteer
Quote:
Originally Posted by {JT}
Do you have an example page to your work around? I recently fixed a bug with the SmugMug viewing style where a gallery would not load if you sent a link with a hash tag that we did not expect (we look for ImageID, Page # or Lightbox).

However, if you are referring to a non-gallery page, then you are probably out of luck
JT, if you're looking for an example of where this doesn't work, it's in his previously mentioned thread. He has placed an anchor in a gallery. He wants to go directly to that anchor from another page. Here's the link that doesn't go to the anchor:

http://www.ravensphotography.smugmug...7JU6#PORTRAITS
__________________
--John
HomepagePopular
JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Old Aug-19-2009, 09:00 AM
#6
{JT} is offline {JT}
Code Monkey
{JT}'s Avatar
Yes, I see. Some of these may not work until we have updated all of the styles to support ajax w/ fragment identifiers. Even then, we will have to work out a method to support old style urls.

Quote:
Originally Posted by jfriend
JT, if you're looking for an example of where this doesn't work, it's in his previously mentioned thread. He has placed an anchor in a gallery. He wants to go directly to that anchor from another page. Here's the link that doesn't go to the anchor:

http://www.ravensphotography.smugmug...7JU6#PORTRAITS
Old Aug-20-2009, 03:05 PM
#7
Tinkersdamn is offline Tinkersdamn OP
Big grins
Quote:
Originally Posted by {JT}
What I found out is that the browser does not send the fragment identifier or hash tag to the server when it requests a web page. The browser only sends the important part of the URL - but keeps that hash tag for itself to use. (Some browsers MAY send the fragment identifier - but certainly not the majority of them).

The only work around I know is to have a little bit of javascript at the top of your page that looks for location.hash and reloads it if it finds anything (after the page loads).

I hope that makes sense, if not just let me know and I can try again :)
Well thanks, I did not know that. Learn something every day...

I think the problem then is that the URI returned to the browser is NOT the one that is sent to the server. It comes back different in most cases.

Here is what I see going on -

Assume - gallery URI is \gallery\n-k
Assume - gallery page contains an anchor with id="foo" (or name="foo") somewhere on the page,

Then -

CASE #1: STARTING POINT IS THE GALLERY PAGE (\gallery\n-k)
You click on an anchor containing an href=#foo you will be taken to the proper position inside the page (the spot containing the anchor with id="foo").

This now makes sense to me based on what you said about browser behavior. The browser already has the identified resource loaded so it just jumps to the anchor in the page it has cached and does not request anything from the server.

CASE #2: YOU ARE ON ANY OTHER PAGE
Your browser requests the URI -
\gallery\n-k#foo

the URI comes back mangled as -
\gallery\n-k\1\foo

but the same page gets returned. (i.e. same as if you had gone to \gallery\xxx-yyy)
And of course once it is loaded, since it is the same page and the browser now has it loaded, you can now get to the right place from there if you try \gallery\n-k\1\foo#foo.

But if you are coming from anywhere else then -

[FONT=Courier New] a link to ... takes you to ... (top of page)
----------------------------------------------------------------
\gallery\n-k#foo --> \gallery\n-k\1\foo
\gallery\n-k\1#foo --> \gallery\n-k\1\foo
\gallery\n-k\1\foo#foo --> \gallery\n-k\1\foo

[/FONT] I'm a bit surprised that the last one above does not work since the URI returned is the same as the one requested. I think the browser (I'm using FF 3.5.2) must not trust what is returned to be complete even in this case.

I'm not very experienced with how the browser does page processing but could it be that in the last case it does not look for the anchor because it invalidates the resource after it runs javascript on the page it just loaded? I have JS (Top JS) in this page to suppress links on the photos.

Code:
 /* --- Journal No Link Images ------------                              */
/* This code enables a Journal style without the images being links */
function doOnLoad() {
  if (window.AlbumID && (window.AlbumID == "8285063")) //
  removeLinkFromImg();
}

function removeLinkFromImg()
{
    var links = document.getElementsByTagName("A");
    for (var i = 0; i < links.length; i++)
    {
        var link = links[i];
        var divElm = link.parentNode;
        if (!divElm)
            continue;
        divElm = divElm.parentNode;
        if (!divElm)
            continue;
        if (divElm.className.indexOf("photo")<0)
            continue;
        link.href = "javascript:void(0);";
    }
}
/* --- End: Journal No Link Images ----- */
[There is also "Bottom" JS to make the home page behave like a .gallery page]
Old Aug-20-2009, 03:57 PM
#8
{JT} is offline {JT}
Code Monkey
{JT}'s Avatar
I get it now. I will see what can be done, I am pretty sure I know what the culprit is.


Quote:
Originally Posted by Tinkersdamn
Well thanks, I did not know that. Learn something every day...

I think the problem then is that the URI returned to the browser is NOT the one that is sent to the server. It comes back different in most cases.

Here is what I see going on -

Assume - gallery URI is \gallery\n-k
Assume - gallery page contains an anchor with id="foo" (or name="foo") somewhere on the page,

Then -

CASE #1: STARTING POINT IS THE GALLERY PAGE (\gallery\n-k)
You click on an anchor containing an href=#foo you will be taken to the proper position inside the page (the spot containing the anchor with id="foo").

This now makes sense to me based on what you said about browser behavior. The browser already has the identified resource loaded so it just jumps to the anchor in the page it has cached and does not request anything from the server.

CASE #2: YOU ARE ON ANY OTHER PAGE
Your browser requests the URI -
\gallery\n-k#foo

the URI comes back mangled as -
\gallery\n-k\1\foo

but the same page gets returned. (i.e. same as if you had gone to \gallery\xxx-yyy)
And of course once it is loaded, since it is the same page and the browser now has it loaded, you can now get to the right place from there if you try \gallery\n-k\1\foo#foo.

But if you are coming from anywhere else then -

[FONT=Courier New] a link to ... takes you to ... (top of page)
----------------------------------------------------------------
\gallery\n-k#foo --> \gallery\n-k\1\foo
\gallery\n-k\1#foo --> \gallery\n-k\1\foo
\gallery\n-k\1\foo#foo --> \gallery\n-k\1\foo

[/FONT] I'm a bit surprised that the last one above does not work since the URI returned is the same as the one requested. I think the browser (I'm using FF 3.5.2) must not trust what is returned to be complete even in this case.

I'm not very experienced with how the browser does page processing but could it be that in the last case it does not look for the anchor because it invalidates the resource after it runs javascript on the page it just loaded? I have JS (Top JS) in this page to suppress links on the photos.

Code:
 /* --- Journal No Link Images ------------                              */
/* This code enables a Journal style without the images being links */
function doOnLoad() {
  if (window.AlbumID && (window.AlbumID == "8285063")) //
  removeLinkFromImg();
}

function removeLinkFromImg()
{
    var links = document.getElementsByTagName("A");
    for (var i = 0; i < links.length; i++)
    {
        var link = links[i];
        var divElm = link.parentNode;
        if (!divElm)
            continue;
        divElm = divElm.parentNode;
        if (!divElm)
            continue;
        if (divElm.className.indexOf("photo")<0)
            continue;
        link.href = "javascript:void(0);";
    }
}
/* --- End: Journal No Link Images ----- */
[There is also "Bottom" JS to make the home page behave like a .gallery page]
Tell The World!  

Thread Tools
Display Modes

Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump