Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Eric Herlitz 97 posts 129 karma points
    May 01, 2011 @ 23:48
    Eric Herlitz
    0

    Detect if href link is to an internal page

    Hi

    In example

    If i create a link in an article to a page whos address is something like /rfc-articles/article369.aspx, or why not /rfc-articles/article777.aspx.

    What I would like to do is to detect if the link contains /rfc-articles/ and in that case fire a javascript. Is there any built-in support for this in umbraco or do I need to hack it together with jquery? :)

    I'm running Umbraco 4.7.

    Thanks

  • Lesley 284 posts 143 karma points
    May 02, 2011 @ 02:29
    Lesley
    0

    Hi Eric,

    I was going to tell you how to do the simple jquery selector for this on the frontend of your site, but then I realised that you are probably asking a different question! You want to know about detecting which link has been set by the editor in Umbraco at the time of creation?? I'm afraid I don't know the answer to that, but thought it would be useful to clarify the question. Are the links created via the node picker, or entered direct into the html view by the editors (or both)?

  • Eric Herlitz 97 posts 129 karma points
    May 02, 2011 @ 10:36
    Eric Herlitz
    0

    Sorry for the diffuse question.

    I do know about selectors in jQuery and thats what I ended up doing, what I would like do to is to have umbraco to add an attribute on links to internal pages which have a special property set or is heading towards a specific node, as in /rfc-articles/ in my example above.

    But I'll have to figure this later since I'm on a tight schedule, jquery will do for now and here it is

    $('a[href*="rfc-article"]').each(function () {
        var href = $(this).attr("href");
        $(this).attr("href", href + "?iframe=true&width=400&height=450");
        $(this).attr("rel", "prettyPhoto[rfcarticle]");
    });
    I add some data to the href attribute and add the rel attribute.
    Cheers

Please Sign in or register to post replies

Write your reply to:

Draft