Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Guilherme baiano

Mouse Event - Clique por coordenadas ao carregar page

Recommended Posts

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>

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

  • Conteúdo Similar

    • Por gugacamacho
      Senhores,
       
      Necessito muito da ajuda, estou com este codigo abaixo, quando insiro as variaveis para chamar a funcao, o calculo esta errado. por gentileza, se alguem pode me ajudar
      <% 'set rs = Conn.Execute("SELECT * FROM ctos ORDER by codigo") Function DegRad(x) 'Degrees to Radians DegRad = x * ((4 * Atn(1)) / 180) End Function Function GetGeodesicDistance(Lat1,Lon1,Lat2,Lon2,rScale) Dim er,pr,fl,F,G,L,S,C,W,R,D,H1,H2 er = 6378.1370000 pr = 6356.7523142 fl = (er - pr) / er F = (DegRad(Lat1) + DegRad(Lat2)) / 2 G = (DegRad(Lat1) - DegRad(Lat2)) / 2 L = (DegRad(Lon1) - DegRad(Lon2)) / 2 S = Sin(G)^2 * Cos(L)^2 + Cos(F)^2 * Sin(L)^2 C = Cos(G)^2 * Cos(L)^2 + Sin(F)^2 * Sin(L)^2 W = Atn(Sqr(S / C)) R = Sqr(S * C) / W D = 2 * W * er H1 = (3 * R - 1) / (2 * C) H2 = (3 * R + 1) / (2 * S) Select Case rScale Case "statute" dScale = 1.60934 Case "nautical" dScale = 1.85200 Case "metric" dScale = 1.00000 Case Else dScale = 1.60934 End Select GetGeodesicDistance = (D * (1 + fl * H1 * Sin(F)^2 * Cos(G)^2 - fl * H2 * Cos(F)^2 * Sin(G)^2)) / dScale End Function %> <div align="center"> <form name="frm" method="post" action="mapa_v.asp"> <label>Posição do cliente <input name="latitude" type="text" id="latitude" value=-28.401684> <input name="longitude" type="text" id="longitude" value=-49.389643> </label> <label> <input type="submit" name="Submit" value="Enviar"> </label> </form> </div> <% dim Lati0, Long0, Lati1, Long1 lati0 = request.form("latitude") long0 = request.form("longitude") response.write GetGeodesicDistance(-28.401684,-49.389643,-28.394418,-49.395537, "metric") & " RESULTADO CORRETO<br><br><br>" Lati1 = "-28.394418" Long1 = "-49.395537" response.Write(lati0) & "," response.Write(Long0) & "," response.Write(lati1) & "," response.Write(Long1) & "<br><br><br>" 'Display calc response.write GetGeodesicDistance(Lati0,Long0,Lati1,Long1, "metric") & " RESULTADO DO CALCULO<br>" %>  
    • Por gugacamacho
      Senhores, bom dia...
       
      Estou com um grande problema com este script para calcular distancia entre coordenadas, o erro se dá quando eu uso a informacao do formulario, ele nao le a coordenada correta, mas quando insiro de maneira estatica, funciona normal... preciso de muita a ajuda de todos.
      <%@ Language=VBScript %> <!--#include file="cnx_map.asp"--> <% 'set rs = Conn.Execute("SELECT * FROM ctos ORDER by codigo") Function DegRad(x) 'Degrees to Radians DegRad = x * ((4 * Atn(1)) / 180) End Function Function GetGeodesicDistance(Lat1,Lon1,Lat2,Lon2,rScale) Dim er,pr,fl,F,G,L,S,C,W,R,D,H1,H2 er = 6378.1370000 pr = 6356.7523142 fl = (er - pr) / er F = (DegRad(Lat1) + DegRad(Lat2)) / 2 G = (DegRad(Lat1) - DegRad(Lat2)) / 2 L = (DegRad(Lon1) - DegRad(Lon2)) / 2 S = Sin(G)^2 * Cos(L)^2 + Cos(F)^2 * Sin(L)^2 C = Cos(G)^2 * Cos(L)^2 + Sin(F)^2 * Sin(L)^2 W = Atn(Sqr(S / C)) R = Sqr(S * C) / W D = 2 * W * er H1 = (3 * R - 1) / (2 * C) H2 = (3 * R + 1) / (2 * S) Select Case rScale Case "statute" dScale = 1.60934 Case "nautical" dScale = 1.85200 Case "metric" dScale = 1.00000 Case Else dScale = 1.60934 End Select GetGeodesicDistance = (D * (1 + fl * H1 * Sin(F)^2 * Cos(G)^2 - fl * H2 * Cos(F)^2 * Sin(G)^2)) / dScale End Function %> <div align="center"> <form name="frm" method="post" action="mapa_v.asp"> <label>Posição do cliente <input name="latitude" type="text" id="latitude" value=-28.401684> <input name="longitude" type="text" id="longitude" value=-49.389643> </label> <label> <input type="submit" name="Submit" value="Enviar"> </label> </form> </div> <% dim Lati0, Long0, Lati1, Long1 lati0 = request.form("latitude") long0 = request.form("longitude") response.write GetGeodesicDistance(-28.401684,-49.389643,-28.394418,-49.395537, "metric") & " RESULTADO CORRETO<br><br><br>" Lati1 = "-28.394418" Long1 = "-49.395537" response.Write(lati0) & "," response.Write(Long0) & "," response.Write(lati1) & "," response.Write(Long1) & "<br><br><br>" 'Display calc response.write GetGeodesicDistance(Lati0,Long0,Lati1,Long1, "metric") & " RESULTADO DO CALCULO<br>" %> [Click e arraste para mover]  
    • Por JosimarNew
      Olá a todos. Gostaria de saber se alguém conhece algum programa para restringir o movimento do mouse no centro da tela do pc.
       
      Exemplo: o ponteiro do mouse deverá se movimentar apenas no centro da tela em não ultrapassando as coordenadas definidas pelo programa, sendo que essa área onde o ponteiro deverá se movimentar tem que ser um área circular.
       
      Parecido com isso.

    • Por Jorge Gomess
      Boa noite!
       
      A situação é a seguinte, estou incluindo páginas dentro de iframes, sendo que as mesmas fazem parte do mesmo domínio, existem campos e seus valores máximos, e também um botão para selecionar todos os valores máximos destes campos, e este é meu objetivo, clicar nesse botão, porém, quando disparo o evento clique, nada é selecionado, entretanto, observei que adicionar valores manualmente a estes campos funcionava. 
       
      Segue o código utilizado para disparar evento clique e selecionar o valor máximo de todos os campos:
      $('#praca0').contents().find('#todasUnidades').click(); Isto é o que funciona:
      $('#praca0').contents().find('#campo1').val('10'); Contudo, eu não quero fazer isso para cada campo, sendo que já tenho um botão que seleciona todos os valores máximos.
       
      Vale ressaltar que se disparar o evento clique nas respectivas páginas sem estarem dentro de iframes tudo ocorre como esperado.
       
      Desde já agradeço pela ajuda!
    • Por BrunoHSL
      E ai galera, seguinte estou fazendo um projeto e preciso da ajuda de vocês rs, coloquei uma imagem numa determinada variável e a cada clique no teclado ele movimenta 50px dependendo da onde ele quer movimentar, ele movimenta como quero porém fica ele fica um "rastro" na onde passa, e quero que apague o elemento anterior, afim de dar uma sensação meio de movimento, vou publicar o código aqui e ficaria muito agradecido se pudessem me ajudar, obs : o codigo deve ser feito todo em Javascript... Obrigado desde já.
      <html> <head> <meta charset='utf-8'> <script> var i, j; var m = []; var x=0; var y=0; var canvas; var ctx; var imagem = new Image(); imagem.src = "link da imagem 2"; var x = 202; var y = 352; function fase1() { canvas = document.getElementById("canvas"); ctx = canvas.getContext("2d"); tabela(); ctx.drawImage(m[7][1],102,102); player(); } function tabela() { canvas = document.getElementById("canvas"); ctx = canvas.getContext("2d"); for (i=0;i<9;i++) { m[i]=[]; } for(i=0;i<9;i++) { for(j=0;j<9;j++) { m[0][0]=ctx.fillStyle="gray"; ctx.fillRect(0,0,50,50); m[0][1]=ctx.fillStyle="lightgray"; ctx.fillRect(50,0,50,50); m[0][2]=ctx.fillStyle="gray"; ctx.fillRect(100,0,50,50); m[0][3]=ctx.fillStyle="lightgray"; ctx.fillRect(150,0,50,50); m[0][4]=ctx.fillStyle="gray"; ctx.fillRect(200,0,50,50); m[0][5]=ctx.fillStyle="lightgray"; ctx.fillRect(250,0,50,50); m[0][6]=ctx.fillStyle="gray"; ctx.fillRect(300,0,50,50); m[0][7]=ctx.fillStyle="lightgray"; ctx.fillRect(350,0,50,50); m[0][8]=ctx.fillStyle="lightgray"; ctx.fillRect(0,50,50,50); m[1][0]=ctx.fillStyle="gray"; ctx.fillRect(50,50,50,50); m[1][1]=ctx.fillStyle="lightgray"; ctx.fillRect(100,50,50,50); m[1][2]=ctx.fillStyle="gray"; ctx.fillRect(150,50,50,50); m[1][3]=ctx.fillStyle="lightgray"; ctx.fillRect(200,50,50,50); m[1][4]=ctx.fillStyle="gray"; ctx.fillRect(250,50,50,50); m[1][5]=ctx.fillStyle="lightgray"; ctx.fillRect(300,50,50,50); m[1][6]=ctx.fillStyle="gray"; ctx.fillRect(350,50,50,50); m[1][7]=ctx.fillStyle="gray"; ctx.fillRect(0,100,50,50); m[1][8]=ctx.fillStyle="lightgray"; ctx.fillRect(50,100,50,50); m[2][0]=ctx.fillStyle="gray"; ctx.fillRect(100,100,50,50); m[2][1]=ctx.fillStyle="lightgray"; ctx.fillRect(150,100,50,50); m[2][2]=ctx.fillStyle="gray"; ctx.fillRect(200,100,50,50); m[2][3]=ctx.fillStyle="lightgray"; ctx.fillRect(250,100,50,50); m[2][4]=ctx.fillStyle="gray"; ctx.fillRect(300,100,50,50); m[2][5]=ctx.fillStyle="lightgray"; ctx.fillRect(350,100,50,50); m[2][6]=ctx.fillStyle="lightgray"; ctx.fillRect(0,150,50,50); m[2][7]=ctx.fillStyle="gray"; ctx.fillRect(50,150,50,50); m[2][8]=ctx.fillStyle="lightgray"; ctx.fillRect(100,150,50,50); m[3][0]=ctx.fillStyle="gray"; ctx.fillRect(150,150,50,50); m[3][1]=ctx.fillStyle="lightgray"; ctx.fillRect(200,150,50,50); m[3][2]=ctx.fillStyle="gray"; ctx.fillRect(250,150,50,50); m[3][3]=ctx.fillStyle="lightgray"; ctx.fillRect(300,150,50,50); m[3][4]=ctx.fillStyle="gray"; ctx.fillRect(350,150,50,50); m[3][5]=ctx.fillStyle="gray"; ctx.fillRect(0,200,50,50); m[3][6]=ctx.fillStyle="lightgray"; ctx.fillRect(50,200,50,50); m[3][7]=ctx.fillStyle="gray"; ctx.fillRect(100,200,50,50); m[3][8]=ctx.fillStyle="lightgray"; ctx.fillRect(150,200,50,50); m[4][0]=ctx.fillStyle="gray"; ctx.fillRect(200,200,50,50); m[4][1]=ctx.fillStyle="lightgray"; ctx.fillRect(250,200,50,50); m[4][2]=ctx.fillStyle="gray"; ctx.fillRect(300,200,50,50); m[4][3]=ctx.fillStyle="lightgray"; ctx.fillRect(350,200,50,50); m[4][4]=ctx.fillStyle="lightgray"; ctx.fillRect(0,250,50,50); m[4][5]=ctx.fillStyle="gray"; ctx.fillRect(50,250,50,50); m[4][6]=ctx.fillStyle="lightgray"; ctx.fillRect(100,250,50,50); m[4][7]=ctx.fillStyle="gray"; ctx.fillRect(150,250,50,50); m[4][8]=ctx.fillStyle="lightgray"; ctx.fillRect(200,250,50,50); m[5][0]=ctx.fillStyle="gray"; ctx.fillRect(250,250,50,50); m[5][1]=ctx.fillStyle="lightgray"; ctx.fillRect(300,250,50,50); m[5][2]=ctx.fillStyle="gray"; ctx.fillRect(350,250,50,50); m[5][3]=ctx.fillStyle="gray"; ctx.fillRect(0,300,50,50); m[5][4]=ctx.fillStyle="lightgray"; ctx.fillRect(50,300,50,50); m[5][5]=ctx.fillStyle="gray"; ctx.fillRect(100,300,50,50); m[5][6]=ctx.fillStyle="lightgray"; ctx.fillRect(150,300,50,50); m[5][7]=ctx.fillStyle="gray"; ctx.fillRect(200,300,50,50); m[5][8]=ctx.fillStyle="lightgray"; ctx.fillRect(250,300,50,50); m[6][0]=ctx.fillStyle="gray"; ctx.fillRect(300,300,50,50); m[6][1]=ctx.fillStyle="lightgray"; ctx.fillRect(350,300,50,50); m[6][2]=ctx.fillStyle="lightgray"; ctx.fillRect(0,350,50,50); m[6][3]=ctx.fillStyle="gray"; ctx.fillRect(50,350,50,50); m[6][4]=ctx.fillStyle="lightgray"; ctx.fillRect(100,350,50,50); m[6][5]=ctx.fillStyle="gray"; ctx.fillRect(150,350,50,50); m[6][6]=ctx.fillStyle="lightgray"; ctx.fillRect(200,350,50,50); m[6][7]=ctx.fillStyle="gray"; ctx.fillRect(250,350,50,50); m[6][8]=ctx.fillStyle="lightgray"; ctx.fillRect(300,350,50,50); m[7][0]=ctx.fillStyle="gray"; ctx.fillRect(350,350,50,50); m[7][1]=document.getElementById("i1"); } } } function player(){ imagem.onload = function(){ ctx.drawImage(imagem, x, y, imagem.width, imagem.height); } document.onkeydown = function(event) { switch(event.which) { case 37: //pra esquerda x = x - 50; break; case 38: //pra cima y = y - 50; break; case 39: //pra direita x = x + 50; break; case 40: //pra baixo y = y + 50; break; } } setInterval(function(){ ctx.drawImage(imagem, x, y, imagem.width, imagem.height); }, 50); } </script> </head> <body onload="fase1()"> <canvas id="canvas" width="400" height="400" style="border: solid 0px black; margin: 0px auto; display: block;"> <img src="link da imagem 1" id="i1"> </canvas> </body> </html> A imagem 1, só deixei ele numa determinada coordenada, pois vou mexer nela depois.
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.