Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide <canvas> element

Somewhere in my javascript code, there is a function which injects a canvas element in my code . The canvas element is being displayed for 10 seconds then it disappears.

This is the code that is being injected..

<canvas style="position: absolute; bottom: 15px; top: auto; left: 15px; z-index: 100000; visibility: visible; cursor: pointer;" y="0" x="0" height="17" width="46"></canvas>

The problem is that i can't find that bit of code in my javascript. Is there another way to hide the completely?

like image 541
user2093301 Avatar asked Mar 12 '14 18:03

user2093301


People also ask

How do you make invisible canvas?

Complete HTML/CSS Course 2022 The globalAlpha property returns the transparency value of drawing. The value 1.0 of this property specifies no transparency and the value 0.0 of this property specifies full transparency. Hence, by setting the globalAlpha property to 0.0, we can get a transparent canvas.

Can you put HTML elements inside a canvas?

Because browsers will display either a canvas element or HTML controls that you put inside that element, but not both, you must place your controls outside of your canvas elements. To make it appear as though HTML controls are inside a canvas, you can use CSS to place the controls above the canvas.

What does the canvas element do?

<canvas> is an HTML element which can be used to draw graphics via scripting (usually JavaScript). This can, for instance, be used to draw graphs, combine photos, or create simple animations. First introduced in WebKit by Apple for the macOS Dashboard, <canvas> has since been implemented in browsers.


1 Answers

Really?

i can't find that bit of code in my javascript

Anyway,

Assuming(!) that this is the only canvas at x==0,y==2 sized at width==46,height==17 you can use document.querySelector to fetch the canvas and hide it.

// build the query selector for the desired canvas
var query="canvas[x='0'][y='0'][height='17'][width='46']";

// find the canvas
var canvas=document.querySelector(query);

// hide the canvas
canvas.style.display="none";

If there are more canvases with that position and size, you must use querySelectorAll to get a list of all the matching canvas nodes and then iterate that list to find the canvas with the matching style attributes.

like image 158
markE Avatar answered Oct 21 '22 16:10

markE