Quantcast
Channel: Últimos conteúdos
Viewing all articles
Browse latest Browse all 14190

Mouse Event - Clique por coordenadas ao carregar page

$
0
0

Olá pessoal, boa noite.

 

Tô tentando fazer funcionar um sistema em que ao carregar a page ela realiza um clique automaticamente pelas coordenadas X e Y já definidas na codificação, independente do browser. Mas não tá funcionando aqui, já tentei de tudo. Alguém consegue me ajudar ?

 

Segue codificação:

 

<!DOCTYPE html>
<html>
<head>
 
<script>
function mouseEvent(type, sx, sy, cx, cy) {
  var evt;
  var e = {
    bubbles: true,
    cancelable: (type != "mousemove"),
    view: window,
    detail: 0,
    screenX: sx,
    screenY: sy,
    clientX: cx,
    clientY: cy,
    ctrlKey: false,
    altKey: false,
    shiftKey: false,
    metaKey: false,
    button: 0,
    relatedTarget: undefined
  };
    if (typeof( document.createEvent ) == "function") {
      evt = document.createEvent("MouseEvents");
      evt.initMouseEvent(type,
        e.bubbles, e.cancelable, e.view, e.detail,
        e.screenX, e.screenY, e.clientX, e.clientY,
        e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
        e.button, document.body.parentNode);
    } else if (document.createEventObject) {
      evt = document.createEventObject();
      for (prop in e) {
      evt[prop] = e[prop];
    }
      evt.button = { 0:1, 1:4, 2:2 }[evt.button] || evt.button;
    }
    return evt;
  }
  function dispatchEvent (el, evt) {
    if (el.dispatchEvent) {
      el.dispatchEvent(evt);
    } else if (el.fireEvent) {
      el.fireEvent('on' + type, evt);
    }
    return evt;
  }
</script>
</head>
 
<body onload = mouseEvent(click, 1000, 1000, 0, 0); >
<a target = blank href = "http://www.google.com">
<img src="back1.jpg" width="1920" height="1089" border="0">
</a>
</body>
</html>
 

 

 


Viewing all articles
Browse latest Browse all 14190