Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8541087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:45:00+00:00 2026-06-11T11:45:00+00:00

For a website I want to show a custom context menu when a user

  • 0

For a website I want to show a custom context menu when a user “longpresses” the screen. I’ve created a jQuery Longclick listener in my code to show a custom context menu. The context menu is displayed, but the iPad’s default context menu is also displayed! I tried to prevent this by adding a preventDefault() to the event in my listener, but this does not work:

function showContextMenu(e){
  e.preventDefault();
  // code to show custom context menu
}

$("#myId").click(500, showContextMenu);

Questions

  1. Can you prevent the iPad’s default context menu to show?
  2. Can it by done using the jQuery Longclick plugin?

The Longclick plugin has some specific handling for the iPad (assuming by this snippet of it’s source code):

if (!(/iphone|ipad|ipod/i).test(navigator.userAgent)){
  $(this)
  .bind(_mousedown_, schedule)
  .bind([_mousemove_, _mouseup_, _mouseout_, _contextmenu_].join(' '), annul)
  .bind(_click_, click)
}

So I assume this answers my second question (assuming the plugin used the correct event).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:45:01+00:00Added an answer on June 11, 2026 at 11:45 am

    Thanks to JDandChips for pointing me to the solution. It works perfectly in combination with the longclick plugin. For documentation sake I’ll post my own answer to show what I did.

    HTML:

    <script type="text/javascript"
            src="https://raw.github.com/pisi/Longclick/master/jquery.longclick-min.js"></script>
    
    <p><a href="http://www.google.com/">Longclick me!</a></p>
    

    The Javascript already was OK:

    function longClickHandler(e){
      e.preventDefault();
      $("body").append("<p>You longclicked. Nice!</p>");
    }
    
    $("p a").longclick(250, longClickHandler);
    

    The fix was to add these rules to the style sheet:

    body { -webkit-touch-callout: none !important; }
    a { -webkit-user-select: none !important; }
    

    Disabled context menu example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to a build a website that show the user all videos that
In my website , i want to show some data which will be displayed
I want to show notification on my website using Pines Notify jQuery plugin but
I'm developing a website for a survey, and I want to show the user
In my website, when the user logs in, I want to show the user
I am creating a custom reporting website, where I want to show live data
I want to show terms and condition note on my website. I dont want
I want to open a website, change its javascript, then show the website +
I used a iframe tag to show anther website. But I want people click
I want to show a box in 3d on my website, and I was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.