How can I detect clicks on dynamically loaded content in Javascript? [duplicate] - javascript

This question already has answers here:
Attach event to dynamic elements in javascript
(15 answers)
Event binding on dynamically created elements?
(23 answers)
Closed last month.
I need to track clicks on content that is dynamically loaded. The content is ads by Google adsense. You include their script in the header of a webpage:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-0000000000000"
crossorigin="anonymous"></script>
and then the ads are dynamically placed on different locations of the website.
Because we are facing the problem of fraudulent clicks, we'd like to track who is clicking on them. Is it possible to achieve this through Javascript?
Is it a good idea to intercept all clicks on the web page and then check if the clicked content is an ad?
Are there certain characteristics of the dynamically loaded ads that make them identifieable?

Related

Is there a possible way to hide the input from inspect element? [duplicate]

This question already has answers here:
How to hide form code from view code/inspect element browser?
(14 answers)
Closed last year.
I have an input that is hidden and I don't want it to be shown in inspect element. Is there any possible way to do that?
No, there is not. Any HTML element will be accessible through the HTML source, even if generated dynamically through javascript.
If you are trying to secure some information which the client should not have access to, do not send it to the client.

Saving dynamically created HTML elements with JavaScript not using PHP? [duplicate]

This question already has answers here:
How to keep the changes made to DOM by javascript/jquery on page refresh
(2 answers)
How to get JS variable to retain value after page refresh? [duplicate]
(4 answers)
Closed 1 year ago.
Is it possible to save dynamically added HTML elements with JavaScript on HTML page? For example, when I create some HTML element (div, p, li...) using JavaScript, then add it on a page, it appears on the page as it should be, but as soon as I reload or leave the page, and then get back - all those elements disappear. So, how can I do so that they do not disappear after reloading or leaving page (If such is possible).
It is not possible without some backend interaction. But if you need it only for one client (one browser) you can store some details to localStorage and use it on the next load. You have to be aware only one client will be able to see it.

prevent bots to click on clickable images in javascript [duplicate]

This question already has answers here:
Check if event is triggered by a human
(9 answers)
Closed 4 years ago.
I have some images that are clickable. for each click , users can get some point.
But I want to prevent clicks that do by bots. in fact I want a way to detect that a real user is clicked or a bot.
I want do that in javascript or jquery. if anyone know a plugin that can do that Please introduce me to it.
You can simply assume it’s human, provided access to the page is protected by reCAPTCHA, and subsequent requests carry a CSRF token.

Link without tracking source web page [duplicate]

This question already has answers here:
Remove http referer
(10 answers)
Hide Referrer on click
(8 answers)
Is it possible to remove the referrer in PHP before redirected?
(5 answers)
Closed 5 years ago.
I am working on a web with php (laravel 5.4) and I have to generate several links that the user clicking on them does not let you know that the click originated from my web page. The idea is that it seems that the user wrote the link directly in the browser, and that does not relate in any way that clicked from my website. how can I do it? Thanks for your help.
You can do that using javaScript. You need to define a function that accepts a url as parameter and calls the javascript window.open().
Make a regular tag and in its href attribute pass javascript:void(0); so that the default link click action is stopped.
Now define an attribute onClick and call your defined function here and pass the url you want to open.
Please see the example below:
<script type="text/javascript">
function openURL(url)
{
window.open(url);
}
</script>
GOOGLE

HTML5 how to take a print screen on a particular div class or id [duplicate]

This question already has answers here:
Using HTML5/Canvas/JavaScript to take in-browser screenshots
(7 answers)
Closed 9 years ago.
I am using html5 webpage i displayed some product list, this list are inside the div tag this is designed using css. i want to print the product list get the css style.
i need to click a button
that button to capture and display the window particular div class or id.
then to print the div class or id
These links will give you a good idea of what you are looking for
How to take screenshot of a div with JavaScript?
https://www.idontplaydarts.com/2012/04/taking-screenshots-using-xss-and-the-html5-canvas/
They all do it by using HTML Canvas, if you are new to it then here is a tutorial to help you out
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Canvas_tutorial?redirectlocale=en-US&redirectslug=Canvas_tutorial
There are other ways too. You can also do it by using a Javascript API
http://grabz.it/api/javascript/
or
http://html2canvas.hertzen.com/
Hope it helped !

Categories