Need a javascript developer for onclick function

Status
Not open for further replies.

adaptable

Junior Member
Joined
Aug 15, 2014
Messages
124
Reaction score
75
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
 
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>
 
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>

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. :-)
 
Status
Not open for further replies.
This thread has been auto closed due to the forum's thread age policy. Read more.
Back
Top