Copied to clipboard

Flag this post as spam?

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


  • Alexandru 112 posts 272 karma points
    Oct 01, 2013 @ 10:05
    Alexandru
    0

    Issue with the social media links

    Hi, I have those social media buttons put up on my blog and they work fine on an html file. However, when I use the same code in XSLT, I get ONE error only on the LinkedIn link because of some characters which are also present in other links (which of course work fine).

    This is the code:

    <div class="socialBit" id="social-{@id}">
                            <!-- LinkedIn -->
                                <a href="#" onclick="window.open('http://www.linkedin.com/shareArticle?mini=true&url='+encodeURIComponent(location.href+'#comment-{@id}'), 'linkedin-share-dialog', 'width=626,height=436'); return false;"><img src="/SiteDesign/in.png" alt="LinkedIn" /></a>
    
                            <!-- Google+ -->
                                <a href="#" onclick="window.open('https://plus.google.com/share?url='+encodeURIComponent(location.href+'#comment-{@id}'), 'googleplus-share-dialog', 'width=626,height=436'); return false;"><img src="/SiteDesign/g.png" alt="GooglePlus" /></a>
    
                            <!-- Twitter -->
                                <a href="#" onclick="window.open('http://twitter.com/intent/tweet?text='+encodeURIComponent(location.href+'#comment-{@id}'), 'twitter-share-dialog', 'width=626,height=436'); return false;"><img src="/SiteDesign/tw.png" alt="Twitter" /></a>
    
                            <!-- Facebook -->
                                <a href="#" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href+'#comment-{@id}'), 'facebook-share-dialog', 'width=626,height=436'); return false;"><img src="/SiteDesign/fb.png" alt="Facebook" /></a>
                        </div>
    

    The problem lies on this bit from the LinkedIn part:

    url='+
    

    more specifically on the equeals sign. And I get this error:

    The expected token is ';'.

    As I remove the signs that give error it keeps complaining about the next signs.... the " ' " and " + " signs etc...

    Any ideas what could cause this?

  • Kim Nedergaard 37 posts 144 karma points
    Oct 01, 2013 @ 10:41
    Kim Nedergaard
    1

    you need to write your "&" like "&amp;"

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Oct 01, 2013 @ 10:42
    Chriztian Steinmeier
    100

    Hi Alexandru,

    In XML (and thus, XSLT - heck, even in HTML) the ampersand sign (&) must be escaped because it's used for something called entities. So you need to do this:

    <a href="#" onclick="window.open('http://www.linkedin.com/shareArticle?mini=true&amp;url='+encodeURIComponent(location.href+'#comment-{@id}'), 'linkedin-share-dialog', 'width=626,height=436'); return false;"><img src="/SiteDesign/in.png" alt="LinkedIn" /></a>
    

    To get that to work.

    /Chriztian

  • Alexandru 112 posts 272 karma points
    Oct 01, 2013 @ 10:46
    Alexandru
    0

    Right. Silly mistake... Thank you guys! :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies