简体   繁体   中英

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

- (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. If your script executes for more than 10 seconds, the web view stops executing the script. 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 allocations are also limited to 10 MB. The web view raises an exception if you exceed this limit on the total memory allocation for JavaScript.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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