Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Elected by Dogs
Apr 20, 2006
I'd like it to prompt the user (ok/cancel) when clicked, with the messagebox saying "You are leaving example.com. We are not responsible for the content of external sites:\n---\n(the href="")\n---\nPlease make sure this link does not look like phishing,etc"

All external links are class="outbound" and can be modified with onclick/etc.

Is there an easy way to do this?

Adbot
ADBOT LOVES YOU

Elected by Dogs
Apr 20, 2006
Is there a simple way to ask "Are you sure if you want to leave (domain)" on any links clicked that don't match a whitelist of domains (maybe using onunload?)

Googled, couldn't really find anything lightweight

Elected by Dogs
Apr 20, 2006
Scrap the whitelist I guess.. PHP spits out different URL formats right now depending on where the domain is (/external_leaving?gotourl= final destination)

Would it be easier to just make a function asking to click ok/cancel when a link is onclick=""'d?

Elected by Dogs
Apr 20, 2006
I'm trying this and it's not confirming or asking anything:

code:
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
var r = /google\.com|youtube\.com|/i;
$("a").click(function() { if (!r.test(this.href)) { return confirm("You are now leaving this site to go to: \n"+this.href+"\n")} });
</script>

</head>
<body>
<a href="http://go.at.se" rel="nofollow" class="outbound extlink">bad link</a>
</body>
I checked error console on firefox, nothing really popped out - any ideas what's wrong?

(sorry, I'm a total newbie to JS)

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply