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 8393197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:43:10+00:00 2026-06-09T19:43:10+00:00

I wants to show a javascript message box when a user clicks on a

  • 0

I wants to show a javascript message box when a user clicks on a “FORUM” link on WordPress menu.

The message box should show a message like “You are leaving this website…” and once the user confirms the message box, it should open an external link in a new tab.

I had tried this, but it will fire the message box, when ever I leave the website or reload the page. I just wants this message box on a single WordPress menu item.

I saw some tutorials to do this, but not able to do it on WordPress menu.

WordPress does not recognize javascript:void(0) or any other javascript function on URL part.

Any ideas??

  • 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-09T19:43:11+00:00Added an answer on June 9, 2026 at 7:43 pm

    Finally I got it working. I’m explaining it step by step, so someone with similar issue can solve this:

    1. Put # in your wordpress menu url in which you want the JavaScript
      Function.
    2. Track this menu url (li ID) link from source code. in my case li id
      is menu-item-88. (this id is auto generated by wordpress and
      always unique)
    3. Place the following code before the end of head tag (open header.php
      find </head>) of current theme.
    4. Don’t forget to change the menu-id menu-item-88 to yours.

    <script type="text/javascript">

    jQuery.noConflict();
    jQuery(document).ready(function(){
    var menuID = jQuery('#menu-item-82');
    
    findA = menuID.find('a');
    
    findA.click(function(event){
    if(confirm("YOU ARE LEAVING THE WEBSITE" + '\n' + "" + '\n' + "You are about to leaving the website to go to the external forum" + '\n' + "" + '\n' + "The FORUM will open in a new tab")) 
    {
    window.open('http://www.yourforum.com/','_blank'); //This will open the website in a new tab
    }
    
    });
    });
    </script>
    

    This requires jQuery. So if jQuery is not loaded, add the following line also to your head.

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    

    This will prompt you that, you are leaving the website. If you clicks OK, it will open the given link in a new tab.

    Ok. Thats all.. This will do the magic.

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

Sidebar

Related Questions

I am using this jquery javascript function to show status message, function topBar(message) {
when user changes password I want to show message Successfully changed! and when user
I would like to show a simple confirmation dialog box show before running a
I want to display to the user a message that says please enable JavaScript
I'm developing a website in php. I want to show a message something like
What is the best way to show a message to user after session is
I need to call a validator to show an error message from JavaScript For
I have a javascript box popping up with some message in it but I
I'm developing an OAuth authentication flow purely in JavaScript and I want to show
I want to open a website, change its javascript, then show the website +

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.