1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need a javascript developer for onclick function

Discussion in 'Hire a Freelancer' started by adaptable, Mar 15, 2016.

  1. adaptable

    adaptable Junior Member

    Joined:
    Aug 15, 2014
    Messages:
    110
    Likes Received:
    73
    Hi guys,

    I think I am looking for a javascript developer (I think) - I honestly do not know much about it nor if it's possible to make.

    Here's the current scenario;
    My links/images/whatever contains both an href and an onclick function.
    So when a user clicks it, it opens two new pages; href in same windows and onclick function in a new window.
    Code:
    <a href="http://www.website01.com" onclick="window.open('http://www.website02.com');">TEXT</a>
    This way the browser does not block/warn or anything when "opening" two links.

    What I am looking for;
    The same thing happening just by applying a class to any element e.g.:
    Code:
    <a href="http://www.website01.com" class="website02">TEXT</a>
    And when it's clicked, a "script" triggers the onclick function based on the class "website02"
    The goal is to avoid any browser warnings.

    Let me know if this is possible and feel free to drop me a PM with price.
    Best regards
     
  2. gimme4free

    gimme4free Executive VIP Jr. VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,928
    Likes Received:
    1,944
    Home Page:
    HTML:
    <html>
    <head>
    <script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
    <script>
    $(document).on("click", "#mylink", function(){window.open('http://www.website02.com');});
    </script>
    </head>
    <body>
    <a href="http://www.website01.com" id="mylink">TEXT</a>
    </body>
    </html>
    
     
    • Thanks Thanks x 5
  3. sockpuppet

    sockpuppet Junior Member

    Joined:
    Nov 7, 2011
    Messages:
    155
    Likes Received:
    145
    • Thanks Thanks x 1
  4. adaptable

    adaptable Junior Member

    Joined:
    Aug 15, 2014
    Messages:
    110
    Likes Received:
    73
    Brilliant!
    I just changed it from ID to class and it now works as I wanted.
    Thanks!

    Feel free to send me your PayPal and I will send you beer money. :)