what is the trick, when a user go to an external link of my page an alert, or confirm box appear, or run some other code?

Member Avatar for rakhi4110

what is the trick, when a user go to an external link of my page an alert, or confirm box appear, or run some other code?

Well, you can use scripts to display such message boxes or confirm boxes when an user clicks on those links to external pages..

For ex:

<a href="xyz.com" onClick="msg()">Click Here!! </a>
<script language="javascript>
function msg()
{
alert('this link redirects to an external page');
}
</script>

You may also use confirm box to display an yes or no kinda thing..
I dont know whether the info you requested can be understood by my explanation. If its fine then thank you..

there isn't any general function for all links whentarget is not of my domain, but external domain appear this message?

Member Avatar for rakhi4110

there isn't any general function for all links whentarget is not of my domain, but external domain appear this message?

I am not exactly sure about that. But upon searching for some similar thing i stuumbled upon two links where something related to your request was found.

1.Detecting when an user is leaving your domain
http://www.irt.org/script/257.htm

2.Detecting browser close events
http://www.webdeveloper.com/forum/showthread.php?t=93810

3. And for much detailed info you can view this post..
http://www.eggheadcafe.com/community/aspnet/3/10152504/detect-a-user-leaving-the-site.aspx


Inform me if this was helpful

any way detect, if type in browser a foreign url?

Member Avatar for rakhi4110

I'm not sure about that.. i think u can try this and see if it works..

window.onunload = function() {
    alert("You're leaving this page.");
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.