Jump to content
Sign in to follow this  
skendo

On click hide banner

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

But can this work for a banner that is already based on Javascript and not   my own create HTML image banner. 
because need to use this for adhitz banner. 

Share this post


Link to post
Share on other sites

Sure. Put the script which dynamically generates the banner in a div and just hide the div after it's clicked.

Edited by hansford

Share this post


Link to post
Share on other sites
Posted (edited)

This is my adhitz code: <script type="text/javascript" src="https://adhitzads.com/1078536"></script>

For which place I need insert it?

Edited by dergsa12

Share this post


Link to post
Share on other sites

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.

Sign in to follow this  

×
×
  • 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.