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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:14:58+00:00 2026-05-25T00:14:58+00:00

I have most of this script written but I know I am missing one

  • 0

I have most of this script written but I know I am missing one key pice.

I need to call function (see below)…

function InternalLink() {
Page_ShowPopOnExit = false;
}

…in an if/else statement somehow inside (see code below) to detect that what has been clicked was an internal link and not a page close/external link.

    function LinkConvert() {
var href;
                var anchors = document.getElementsByTagName('a');

                for(var y=0; y<anchors.length; y++)
                {
                                href = anchors[y].href.toLowerCase();
                                if (!(href.indexOf("http://")!=-1 && href.indexOf(MySiteDomain)==-1))
                                                {
                                                anchors[y].clickhandler=InternalLink()
                                                XBrowserAddHandlerPops(anchors[y],"click","clickhandler");
                                                }
                }
}

The (latest) total code is below, Ty for helping me finish my code (or fix it 🙂

function exitwindow() {
var Page_ShowPopOnExit=true;
var MySiteDomain='www.example.com';
var url = '/exit.html';
var win = 'toolbar=0,directories=0,menubar=0,scrollbars=0,resizable=0,width=250,height=300';
if (Page_ShowPopOnExit==true){
   open(url,'WindowName',win);
   } else (Page_ShowPopOnExit==false)
   {alert('Internal Link')}
}

function InternalLink() {
  Page_ShowPopOnExit = false;
}

function LinkConvert() {
var href;
                var anchors = document.getElementsByTagName('a');

                for(var y=0; y<anchors.length; y++)
                {
                                href = anchors[y].href.toLowerCase();
                                if (!(href.indexOf("http://")!=-1 && href.indexOf(MySiteDomain)==-1))
                                                {
                                                anchors[y].clickhandler=InternalLink()
                                                XBrowserAddHandlerPops(anchors[y],"click","clickhandler");
                                                }
                }
}
function XBrowserAddHandlerPops(target,eventName,handlerName) {
  if ( target.addEventListener ) {
    target.addEventListener(eventName, function(e){target[handlerName](e);}, false);
  } else if ( target.attachEvent ) {
    target.attachEvent("on" + eventName, function(e){target[handlerName](e);});
  } else {
    var originalHandler = target["on" + eventName];
    if ( originalHandler ) {
      target["on" + eventName] = function(e){originalHandler(e);target[handlerName](e);};
    } else {
      target["on" + eventName] = target[handlerName];
    }
  }
}
  • 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-25T00:14:58+00:00Added an answer on May 25, 2026 at 12:14 am

    Guessing from your code you want to make a popup when a visitor clicks a link that links to different domain.

    Your code currently does this by attaching an onclick handler to all links if the link URL looks like an internal link (there is no “http://” or the domain is present). It will then set a boolean Page_ShowPopOnExit to false which should prevent the popup hook from generating a popup when it is called (exitwindow – which isn’t being called in your sample code)

    I think there is a simpler way. Namely just attach an onclick handler that will make a popup to each link that isn’t an internal link:

    function createPopup() {
        var url = '/exitexample.html';
        var win ='toolbar=0,directories=0,menubar=0,scrollbars=0,resizable=0,width=250,height=300';
        open(url,'WindowName',win);
    }
    
    var anchors = document.getElementsByTagName('a');
    for(var y=0; y<anchors.length; y++) {
        href = anchors[y].href.toLowerCase();
        if (href.indexOf("http://") !== -1 && href.indexOf(MySiteDomain) !==-1) {
            anchors[y].onclick = createPopup; // you might want to replace this with attachEventListener etc.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have viewed most of the other threads regarding this error but have not
This not a programming question but Most of the programmers using Eclipse should have
I have a messageboard and one of my users has written a greasemonkey script
I know that there have been plenty of topics describing this topic but I
I have a specific script written in Ruby that needs root privileges. Most of
I have this query to calculate the most common days of the week and
I have this string: B82V16814133260 what would be the most efficient way to get
This post on SO answers most of the questions I have (much thanks to
I have a 2d array that looks like this: XX xx What's the most
Most schemas' tables have last_updated_date and last_updated_by columns. I knew how to populate this

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.