简体   繁体   English

我可以在Android的Webview中使用onclick Javascript来确定X和Y吗?

[英]Can I use onclick Javascript in Webview in Android to determine X and Y?

I have made a game in Javascript that I want to make into an Android app.. So obviously using a webView.. 我已经用Javascript开发了一款游戏,想要制作成Android应用程序。

I have a function in Javascript that says if you click on the left hand side of the page, the box will move left - if right it will move right etc. 我在Javascript中有一个函数,它说如果您单击页面的左侧,则该框将向左移动-如果向右,则将向右移动等。

My question is if on my Android phone I click on a specific area of the webView, will it be the same as if I click from a computer? 我的问题是,如果我在Android手机上单击了webView的特定区域,是否与从计算机上单击相同?

The reason I am asking rather than showing what I have done, is that I don't want to implement it into Eclipse to find the idea was redundant. 我之所以问而不是展示自己的工作,是因为我不想在Eclipse中实现它以发现这个想法是多余的。

A WebView is like a browser window. WebView就像浏览器窗口。
So open your page into the android browser and test, if it works as you wish there, it will most likely work about as good in the WebView . 因此,将您的页面打开到android浏览器中并进行测试,如果它在您希望的地方能正常工作,则很有可能在WebView也能正常工作。

Don't forget to enable JavaScript for the WebView : 不要忘记为WebView 启用JavaScript

webview.getSettings().setJavaScriptEnabled(true);

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

相关问题 Javascript,游戏,如何确定div元素相对于JavaScript中父div的位置(x,y)? - Javascript, game, How can I determine the position (x,y) of a div element relative to a parent div in javascript? Android WebView JavaScript onClick错误 - Android WebView JavaScript onClick Bug javascript,如果userlang为X,则onclick值为Y - javascript if userlang is X onclick value is Y 在Android WebView中使用JavaScript - Use javascript in an android webview JavaScript scrollBy(x,y) 不适用于 Android WebView 中的样式列宽 - JavaScript scrollBy(x,y) does not work with style column-width in Android WebView JavaScript onclick在浏览器中有效,在Android WebView中不适用 - JavaScript onclick works in browsers, not in Android WebView 如何使用 {x,y} 对象数组来制作图表? - How can I use an array of {x,y} objects to make a chart? 我们可以使用Android的数据来使用Java在webview中显示数据吗? - Can we use data from android to display it in webview using Javascript? 如何确定textarea光标相对于x,y窗口的位置? - How can i determine the position of textarea cursor relative to the window in x,y? (Javascript)如何从 4 个可能的变量中选择一个随机变量并使用它们的值(x 和 y 坐标)在 Canvas 上绘制图像? - (Javascript) How can I pick a random variable out of 4 possible and use their values (x and y coordinates) to draw an image on Canvas?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM