简体   繁体   English

如何在不使用iPhone野生动物园中的JavaScript的情况下长按打开上下文菜单?

[英]How to open context menu without long press using javascript in iPhone safari?

Is there a way to do something? 有办法吗? :-) :-)

<a href="http://www.google.com/">Long press me!</a>
<script type="text/javascript">
    // do something to open context menu of anchor element
</script>

To run a javascript on a UIWebView you have 要在UIWebView上运行JavaScript

- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script

Parameters
script
The script to run.
Return Value
The result of running script or nil if it fails.

Discussion JavaScript execution time is limited to 10 seconds for each top-level entry point. 讨论每个顶级入口点的JavaScript执行时间限制为10秒。 If your script executes for more than 10 seconds, the web view stops executing the script. 如果您的脚本执行超过10秒,则Web视图将停止执行脚本。 This is likely to occur at a random place in your code, so unintended consequences may result. 这很可能在代码中的任意位置发生,因此可能会导致意想不到的后果。 This limit is imposed because JavaScript execution may cause the main thread to block, so when scripts are running, the user is not able to interact with the webpage. 施加此限制是因为JavaScript执行可能导致主线程阻塞,因此在运行脚本时,用户将无法与网页进行交互。

JavaScript allocations are also limited to 10 MB. JavaScript分配也限制为10 MB。 The web view raises an exception if you exceed this limit on the total memory allocation for JavaScript. 如果您超出JavaScript的总内存分配限制,则Web视图将引发异常。

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

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