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

  • SEARCH
  • Home
  • 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 982915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:46:24+00:00 2026-05-16T04:46:24+00:00

When i click a link, i want to execute a javascript function to get

  • 0

When i click a link, i want to execute a javascript function to get the dynamic url.
So i did like below.

<a href="javascript:myredirect()"> a link </a>

With this code, I cannot see the default context menus provided by browsers like ‘open link in new tab’ or ‘open link in new window’ when i right click the link.
I tried like below too.

<a href="#" onclick="myredirect()"> a link </a>

In this case, i can see the link context menu, but it does not execute the “myredirect()” when i do the ‘open link in new tab’ menu.

Is there a way to run a javascript code when i open link in new tab or new window?

  • 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-05-16T04:46:25+00:00Added an answer on May 16, 2026 at 4:46 am

    Short answer: No, you can’t.

    But since you are using JS anyways, you can just use it to change the href attribute in <a, so by the time the user clilcks on the link, it’s already pointing to the right URL.

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

Sidebar

Related Questions

I want to do something like $('a.filter-link').click(function(e) { e.preventDefault(); var that = $(this), categoryId
I want to change my div content on the click of a link, this
I have an image that I want to execute a link with a javascript
This is script what I have currently - <script type=text/javascript> $(document).ready(function () { $('.RemoveSystem').click(function
I want to toggle element that id's pg when click link. header: <title>Example</title> <script
Here is what I want to happen: The user should click a link/button that
I have some textboxes on a page and I want to click a link
I want people to click on a link (generated from an asp:HyperlinkField) and have
I want to pass a language id for each link i click from my
I want to make a code that counts the click on the link which

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.