简体   繁体   English

单击时使用php调用java脚本函数

[英]Calling a java script function with php on click

Ok so i have paid a coder to code me a walk around map script were users can press up and down on the keyboard and walk aroud a map using jquery. 好的,所以我付了一个编码器给我编码一个遍历地图脚本,用户可以在键盘上上下按下并使用jquery走路地图。 But now im trying to make it so i have a up and down image and then on click it will call the up and down function. 但是现在我试图让它成为一个上下图像然后点击它会调用上下功能。 So the suer can use the up and down keys plus clicking the images. 因此,suer可以使用向上和向下键以及单击图像。

Here is the up function im using for when the user presses the up key on the keyboard. 这是当用户按下键盘上的向上键时使用的向上功能。 But now some how i need to call the same function when a image is clicked.. 但是现在我需要在点击图像时调用相同的函数。

function move(d)
{
    if(d == "UP")
    {
        var top = (parseInt(document.getElementById('move').style.top) - 10);
        var left = parseInt(document.getElementById('move').style.left);
        if(canMove(new xy(left,top)))
        {
            document.getElementById('move').style.top = (parseInt(document.getElementById('move').style.top) - 10) + 'px';
            document.player.src = "maps/sprites/playerUp.png";
            //if(lastStep != "UP") clearTimeouts();
            //setTimeout('document.player.src="playerUp.png"', 500);
            //lastStep = "UP";
            reloadF();
        }
    }

How would i do about doing that ?? 我该怎么办?

Im guessing i just need to call function move(d) and set it to up some how ?? 我猜我只需要调用函数move(d)并将其设置为一些如何? On click of image ? 点击图片?

var keynum = 0;

if(window.event) { keynum = e.keyCode; }  // for IE
else if(e.which) { keynum = e.which; }    // for others browsers

if(keynum === 38) { // up
    //if KEY UP
}

if(keynum === 40) { // down
    //if KEY DOWN
}

I hope this help... 我希望这有帮助......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM