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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:05:19+00:00 2026-06-02T03:05:19+00:00

have a href as follows: <a class=eLink href=http:www.abc.com>chk here xyz</a></li> and javascript for eLink

  • 0

have a href as follows:

<a class="eLink" href="http:www.abc.com">chk here xyz</a></li>

and javascript for “eLink” is as follows:

    $("a.eLink").click(function link(evt) {
        url = evt.target.href;

        if (url.toString().toLowerCase().indexOf(".gov") <= 0) {

            var tk = "Do you really want to continue?";

            if (confirm(tk)) {
                window.open(url, 'newwin');
            }else{
               window.open(url,'_self'); 
            }
        }
        else
        { window.open(url, 'newwin'); }

        return false;
    });
});

Now my issue is when i click the href and click ‘cancel’ in the confirm button, my page goes to “abc.com”, but it shouldnt happen. My browser should remain the same. what script should i use in the else part so i remain the same page. thanks.

  • 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-02T03:05:19+00:00Added an answer on June 2, 2026 at 3:05 am

    Just take the else out.

    if (confirm(tk)) {
        window.open(url, 'newwin');
      }
    

    Sidenote, IE8 and lower doesn’t implement the indexOf function so you may want to patch it by writing your own implementation.

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

Sidebar

Related Questions

I have an NSString as follows: <img alt=996453912 src=http://d2gg0uigdtw9zz.cloudfront.net/large/996453912.jpg /><a href=http://www.dealcatcher.com/shop4tech-coupons>Shop4Tech Coupons</a> I only
We have a JavaScript function named move which does just windows.location.href = any given
I have this code: $('.be-delete').live('click', function(e){ e.preventDefault(); var object =$(this); var url = $(this).attr('href');
I have my function as follows <script type=text/javascript> $(function() { $('#ctl00_ContentPlaceHolder1_TextBox2').datepick(); }); function showDate(date)
THE EXAMPLE First and foremost, here's my code and problem: http://www.nathanstpierre.com/MBX/showoff.html THE ISSUE So
I have used href link in the flexigrid rows. on Click it takes me
i have this code: $('.access a').toggle(function() { $('link').attr('href', 'styles/accessstyles.css'); $('body').css('font-size', '16px'); }, function() {
Possible Duplicate: How to call a JavaScript function from PHP? I have a php
I have this navigation menu: <nav id=hoofd_menu> <a href=portfolio/ title=Portfolio target=_self class=fade portfolio>Portfolio</a> <a
I have a link as follows. @Html.ActionLink(Create Report, Screenreport, Reports, null, new { @class

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.