Jump to content

On click hide banner


skendo

Recommended Posts

Hei everyone. 
i need a solution to find :

When any one clicks on any ad network banner  that i place on site after a click on banner i want it to hide / remove.

I need this so wont have multiple ad clicks and prevent being banned :) 
If some one can help me with the code how to  make  for example adhitz banner after a click made by that visitor to get hidden.

I dont need a function on a simple click anywhere on page.

I need when banner clicked to get hidden after the click is made on it. 

Edited by skendo
Link to comment
Share on other sites

You have 2 options to accomplish this. Using plain JavaScript or with jQuery (or other library). I'll post the JavaScript way.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
<a id="banner" href="http://www.purple.com" target="_blank"><img src="banner.jpg" width="400" height="150"></a>
<script type="text/javascript">

window.onload = function() {
	
	var el = document.getElementById('banner');
	el.addEventListener("click",function() {

		this.style.display = "none";
	});
};

</script>
</body>
</html>
Edited by hansford
Link to comment
Share on other sites

  • 4 years later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.