1

i'm creating a loading Screen for a FiveM server, the thing is I want to display a cursor and FiveM doesn't allow that in the loading screen (we can move the mouse, but the cursor is not showing). So in JS i've created a little script to display a cursor*(image)* depending on the mousemove event:

window.onload = function()
{
  document.body.addEventListener("mousemove", function(event)
  {
    var cursor = document.getElementById("cursor");

    var x = event.clientX - cursor.width + 23;
    var y = event.clientY - 6;
    // console.log("x="+x+"  -  y="+y);

    $("#cursor").css({
        "left": x+"px",
        "top"     : y+"px"
    });
  });
}

My script works well, but not on iframe, the cause is that when the cursor is on the iframe, the JS script doesn't works anymore (it doesn't apply the left/top position so the cursor stays outside of the iframe).

I tried modifying my css but in vain (here it is, i think it will help):

#cursor
{
    position: absolute;
    z-index: 99999!important;
    pointer-events: none;
    width: 40px;
}

iframe {
  z-index: 1;
}

My question is, is it possible to mouve an image hover the iframe (and still being able to use the iframe) ?

Thanks for your help.

geauser
  • 1,005
  • 8
  • 20
tholeb
  • 174
  • 3
  • 13
  • try to add to add position: absolute, also to the css of the cursor. I don't know if it run because i haven't tried it – Matteo Possamai Jun 29 '20 at 13:50
  • your `cursor.width` is `undefined` – ezio4df Jun 29 '20 at 13:53
  • @tholeb change `cursor.width` to `cursor.getClientRects()[0].width` .. are you trying to listen for mouse event on iframe ?? – ezio4df Jun 29 '20 at 13:57
  • @Poss The position class is working fine (I think). And for me the cursor width is well defined, i got no problems, and no, i'm listening only onto the loading screen *(not in the iframe's website itsefl)* – tholeb Jun 29 '20 at 14:11
  • Its probably because of security reasons similar in way https://stackoverflow.com/a/20624274/10794140 – ezio4df Jun 29 '20 at 14:28
  • Yes, that's what I thought, so, not possible I think. Thanks for your help. – tholeb Jun 29 '20 at 14:56

0 Answers0