3

I've seen sites when long pressed the text link URL on mobile browser, eg. Chrome I've tried, it'll display default system pop-up navigation showing the text link context instead of the actual long non-human readable URL/query string.

How can this be done in HTML? or if this is a CSS/JS snippet?

KDX
  • 611
  • 2
  • 10
  • 22
  • you going to need to use a plugin such as hammer js to detect longpress and take appropriate action http://hammerjs.github.io/ -- http://hammerjs.github.io/recognizer-press/ – Tasos Jul 04 '16 at 00:56

1 Answers1

1

https://jsfiddle.net/moongod101/4k2zhs0L/

You can use the setTimeout function

Felix Fong
  • 969
  • 1
  • 8
  • 21
  • Sorry i fix the contextmenu bug,before if you using mobile long press it will show the contextmenu,but now won't – Felix Fong Jul 04 '16 at 03:30
  • I'm testing your example on a mobile device using the Chrome browser. When long press the link, it's displaying the URL. Instead, I would like it to display the text link, `Can you long press me please?` I also don't need this to have js pop up on desktop browser. – KDX Jul 05 '16 at 05:53
  • I help you update the code,if you still got any problem or anythings want to add in this,just call me KDX – Felix Fong Jul 05 '16 at 06:30
  • Thank you for the update, Felix. But I think there is some misunderstanding. I'm not referring at the `alert` popup display. When long press the link in mobile Chrome browser, there's a menu showing: `URL`, `Open`, `Add to Reading List`, `Copy`, and `Cancel`. I'm referring to the `URL` part, that I want to display the text link context `Can you long press me please?` instead of actual `URL` which may contain long query string. – KDX Jul 05 '16 at 06:54
  • If you got time please contact me at http://chat.stackexchange.com,and if you are up there,please leave me know you are there by leaving a comment here thanks – Felix Fong Jul 05 '16 at 09:32