How to use 'document onclick' in JavaScript

Every line of 'document onclick' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
350function DocumentClick (clickEvent)
351{
352 var floating = document.getElementById ('floating');
353 var exporttext = document.getElementById ('exporttext');
354 var svgcontent = document.getElementById ('svgcontent');
355 var isInFloating = false;
356
357 var target = clickEvent.target;
358 while (target !== null) {
359 if (target === floating) {
360 isInFloating = true;
361 break;
362 }
363 target = target.parentElement;
364 }
365
366 if (!isInFloating) {
367 if (floating.style.display !== 'none') {
368 floating.style.display = 'none';
369 exporttext.style.display = 'none';
370 svgcontent.style.display = 'none';
371 }
372 }
373}
64function DocumentClick (clickEvent)
65{
66 var floating = document.getElementById ('floating');
67 var isInFloating = false;
68
69 var target = clickEvent.target;
70 while (target !== null) {
71 if (target === floating) {
72 isInFloating = true;
73 break;
74 }
75 target = target.parentElement;
76 }
77
78 if (!isInFloating) {
79 if (floating.style.display !== 'none') {
80 floating.style.display = 'none';
81 }
82 }
83}

Related snippets