I am attempting to implement a right-click function using only JavaScript. My initial plan was to utilize a mouseover function, as shown below:
mysteryDiv.onmouseover=function(){
if (rightMBclicked === true)
{
console.log(mysteryDiv.id);
}
}
The dilemma I am facing is figuring out how to access 'mysteryDiv'. Below is the function responsible for generating the blocks that I need to interact with, along with some key variables:
var blocknum = 0;
var blockmax = 2500;
var blocks = [];
function createBlocks()
{
if (blocknum < blockmax)
{
blocknum += 1;
var block = document.createElement("div");
block.className = "block";
block.id = "block" + blocknum;
blocks.push(blocknum);
block.style.width = block_width + "px";
block.style.height = block_height + "px";
block.style.cssFloat = "left";
//block.style.backgroundColor = "#228B22";
block.style.backgroundImage="url('textures/grass.jpg')";
document.getElementById("container").appendChild(block,container.firstChild);
createBlocks();
}
else
{
if (blocknum === blockmax)
{
createPlayer();
paused = false;
}
}
}
EDIT:
My objective is to retrieve the ID of the block (mysteryDiv) currently under my mouse cursor.