Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #534708

    Hello guys,
    I have a problem with javascript in a button link I use to encrypt my email address.
    When I use this script in a button link:
    javascript:linkTo_UnCryptMailto(‘nbjmup;ifmmpAyejwfssft/di’);
    nothing append when i heat the button.
    you can try here : https://uiuxdesigner.ch/en/#socket
    But when I use the link in a widget text in another page it works fine
    https://uiuxdesigner.ch/en/portfolio-item/qui-livre-chez-moi-web-service/#socket

    The script associated in the <head> is like this:

    <script type="text/javascript"> <!--
        function UnCryptMailto( s )
        {
            var n = 0;
            var r = "";
            for( var i = 0; i < s.length; i++)
            {
                n = s.charCodeAt( i );
                if( n >= 8364 )
                {
                    n = 128;
                }
                r += String.fromCharCode( n - 1 );
            }
            return r;
        }
    
        function linkTo_UnCryptMailto( s )
        {
            location.href=UnCryptMailto( s );
        }
        // --> </script>

    Do you have an idea of what the problem is ?
    Thanks,
    Xavier

    #534893

    Hey Xavier!

    So your adding this part..

    javascript:linkTo_UnCryptMailto(‘nbjmup;ifmmpAyejwfssft/di’);
    

    To the URL of the button? That’s not going to work. It needs to be added to the onclick attribute. You can right click your page and view it’s source and copy the HTML for the button and then add it into a codeblock element in your page and add the onclick attribute there.

    Regards,
    Elliott

    #535304

    Hey Elliott,

    Thanks for the feedback !
    I copy the code of the button as you said:
    <a href="javascript:linkTo_UnCryptMailto(‘nbjmup;cpokpvsAyejwfssft/di’);" target="_blank" class="avia-button avia-icon_select-no avia-color-theme-color avia-size-large avia-position-left ">Envoyez moi un email</a>
    And paste it in a code block of my page but it is not working.
    You can try it here : https://uiuxdesigner.ch/#socket -(button link on the right)

    the script to unencrypt the email link is in the <head>

    Did I miss something ?

    Xavier

    #538699

    Hey!

    Please remove the modifications then use this in the functions.php file:

    // decrypt
    add_action('wp_footer', 'ava_custom_script');
    function ava_custom_script(){
    ?>
    <script type="text/javascript">
    (function($) {
    	function UnCryptMailto( s )
        {
            var n = 0;
            var r = "";
            for( var i = 0; i < s.length; i++)
            {
                n = s.charCodeAt( i );
                if( n >= 8364 )
                {
                    n = 128;
                }
                r += String.fromCharCode( n - 1 );
            }
            return r;
        }
    
        $('.decrypt_email').on('mouseover', function() {
            $(this).attr('href', UnCryptMailto('nbjmup;cpokpvsAyejwfssft/di'));
        });
    })(jQuery);
    </script>
    <?php
    }

    .. Replace the button code with this:

    <a class="avia-button decrypt_email avia-icon_select-no avia-color-theme-color avia-size-large avia-position-left" href="#">Envoyez moi un email</a>
    

    Best regards,
    Ismael

    #538813

    Thanks for the help, it works perfectly fine !

    #539396

    Hi,

    Great, glad we could help :-)

    Cheers!
    Rikard

    #586419

    hm Ismael – does not work here on my site

    #586945

    Hey!

    Works fine on my end. I’m not sure how he encrypted the email address though (nbjmup;ifmmpAyejwfssft/di).

    Best regards,
    Ismael

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.