Home link with a custom header

NevillePorterNevillePorter Registered Users Posts: 3 Beginner grinner
edited June 23, 2009 in SmugMug Support
Hi there,

I used this code from the help section to change the 'home' link to point towards my homepage rather than the smugmug homepage, yet I cannot seem to get it to work.

// Change Home Link (from Devbobo)
YE.onContentReady('toolbar', function () { this.innerHTML = this.innerHTML.replace(/href="http:\/\/www.smugmug.com\/([?\w&;=]+)?"/, 'href="' + webServer + '"')});

I have trawled through the support and I cant quite figure out why this is the case. Does the fact I have a custom header that replaces the original smugmug logo cause this issue?

Any help would be greatly Appreciated,

Thanks! :D

www.nevilleporter.com

Comments

  • jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited May 11, 2009
    Hi there,

    I used this code from the help section to change the 'home' link to point towards my homepage rather than the smugmug homepage, yet I cannot seem to get it to work.

    // Change Home Link (from Devbobo)
    YE.onContentReady('toolbar', function () { this.innerHTML = this.innerHTML.replace(/href="http:\/\/www.smugmug.com\/([?\w&;=]+)?"/, 'href="' + webServer + '"')});

    I have trawled through the support and I cant quite figure out why this is the case. Does the fact I have a custom header that replaces the original smugmug logo cause this issue?

    Any help would be greatly Appreciated,

    Thanks! :D

    www.nevilleporter.com
    This code does not work with the current version of the Smugmug page and, even if it was changed, it wouldn't work in IE. It would take a different written function to work both with the current page and reliably in all browsers. I might get a chance to write a new function for this later tonight.
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • NevillePorterNevillePorter Registered Users Posts: 3 Beginner grinner
    edited May 11, 2009
    Thankyou so much John. Really appreciated!
  • jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited May 11, 2009
    Hi there,

    I used this code from the help section to change the 'home' link to point towards my homepage rather than the smugmug homepage, yet I cannot seem to get it to work.

    // Change Home Link (from Devbobo)
    YE.onContentReady('toolbar', function () { this.innerHTML = this.innerHTML.replace(/href="http:\/\/www.smugmug.com\/([?\w&;=]+)?"/, 'href="' + webServer + '"')});

    I have trawled through the support and I cant quite figure out why this is the case. Does the fact I have a custom header that replaces the original smugmug logo cause this issue?

    Any help would be greatly Appreciated,

    Thanks! :D

    www.nevilleporter.com

    Try this code instead:
    YE.onContentReady('toolbar', function () 
    {
        var links = this.getElementsByTagName("a");        // get link tags in the toolbar
        if (links.length > 0)
        {
            // examine the first link to see if it's www.smugmug.com
            if (links[0].href.search(/www\.smugmug\.com/i) != -1)
            {
                links[0].href = webServer;        // change the link to point to our own homepage
            }
        }
    });
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited May 11, 2009
    this works...

    YE.onContentReady('toolbar', function () { this.innerHTML = this.innerHTML.replace(/href="http:\/\/www.smugmug.com([?\/\w&;=\-]+)?"/, 'href="' + webServer + '"')});
    David Parry
    SmugMug API Developer
    My Photos
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited May 11, 2009
    jfriend wrote:
    This code does not work with the current version of the Smugmug page and, even if it was changed, it wouldn't work in IE.

    umm, why won't it work in IE ?
    David Parry
    SmugMug API Developer
    My Photos
  • NevillePorterNevillePorter Registered Users Posts: 3 Beginner grinner
    edited May 11, 2009
    That was extremely fast!
    Thankyou so much for your help!
  • jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited May 11, 2009
    devbobo wrote:
    umm, why won't it work in IE ?
    It looks like your new version does work. I was wrong.

    Here's why I do this stuff a different way now. I've found that the innerHTML in IE sometimes does not have quote marks around attributes even though the original source does. I haven't figured out when IE strips them out and when not, but I've made a mental note not to count on them being there. For example CSS class names on a tag don't seem to have quotes around them in the innerHTML even though they do in the source.

    In this particular case, it looks like IE does have quote marks around the link URL in innerHTML, but there are other attributes where it strips them off.

    But, for that reason, I stopped trying to match innerHTML whenever possible and prefer to address the attribute directly in JS which is more consistent across browsers.

    There are also more and more places in the Smugmug pages where setting some innerHTML that also includes flash things or YUI buttons will mess them up such that they no longer work (like setting innerHTML on the breadcrumb object will mess up the slideshow button). So, I try to avoid setting the innerHTML variable whenever I can accomplish what I want by modifying an attribute directly. It also just feels cleaner to me since I'm not resetting a whole bunch of other HTML that I don't even intend to change.
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • VertigoVertigo Registered Users Posts: 27 Big grins
    edited June 23, 2009
    jfriend wrote:
    It looks like your new version does work. I was wrong.

    Here's why I do this stuff a different way now. I've found that the innerHTML in IE sometimes does not have quote marks around attributes even though the original source does. I haven't figured out when IE strips them out and when not, but I've made a mental note not to count on them being there. For example CSS class names on a tag don't seem to have quotes around them in the innerHTML even though they do in the source.

    In this particular case, it looks like IE does have quote marks around the link URL in innerHTML, but there are other attributes where it strips them off.

    But, for that reason, I stopped trying to match innerHTML whenever possible and prefer to address the attribute directly in JS which is more consistent across browsers.

    There are also more and more places in the Smugmug pages where setting some innerHTML that also includes flash things or YUI buttons will mess them up such that they no longer work (like setting innerHTML on the breadcrumb object will mess up the slideshow button). So, I try to avoid setting the innerHTML variable whenever I can accomplish what I want by modifying an attribute directly. It also just feels cleaner to me since I'm not resetting a whole bunch of other HTML that I don't even intend to change.

    Thank you guys....I also tried the first one and nothing...now I am confuse. Which code and where? to direct the Home link to my website? I would really appreciate the help.
Sign In or Register to comment.