Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide Mouse Cursor when it's within HTML5 Canvas Javascript

Tags:

I'm in the process of making a game using Javascript and the html5 canvas element as an alternative to Flash. My question is: is there any bit of code I can use to hide the mouse cursor/pointer as it passes within the canvas? Help is much appreciated!

like image 977
Chris Avatar asked Jul 31 '11 21:07

Chris


Video Answer


2 Answers

I don't think you need Javascript for this, you can just use CSS. Assign your canvas a div id/class, and then use this in your CSS template:

* {cursor: none;}

like image 129
Ankit Soni Avatar answered Sep 28 '22 17:09

Ankit Soni


You can use javascript to manipulate cursor style. Code:

<div id="canvas_div_no_cursor">
   <!-- canvas here -->
</div>
<script type="text/javascript">
  document.getElementById('canvas_div_no_cursor').style.cursor = "none";
</script>
like image 20
VIK Avatar answered Sep 28 '22 17:09

VIK