Is stopping an alert() possible?

I have an alert as one of the first things in my script. I’ve been wondering if it is possible for others to disable that alert if they embed my script? It’s not in a function.


Yup. They can redefine alert to do something else.

	var oldAlert = alert;

	// replace alert with different function
	var alert = function (message) {

	alert('Hello, World!');

	// restore original alert
	alert = oldAlert;

Including alert() calls in a live script is not a good idea. Do you really want some of your visitors to be asked if they want to disable JavaScript for the page

The bottom line of that alert along with the checkbox are built in by the browser so that appears regardless of the message in one browser. Several other browsers ask if you want to disable all alerts if you display a second one. This makes them far more useful for debugging purposes but makes alerts useless for live pages - unless oyu override the alert call to generate your own dialog.

if live then
response.write "if(!(\\^https?\\:\\/\\/(www\\.unitingrhyhtms\\.com)|(www\\.livescript\\.co\\.uk)).test(top.location.href)) alert(""belongs to " & site_name & """);"
end if

I think.

I had a think about this while I was out. Just like a HTML file the javascript is outputted as a “string” from the server to the browser, so there are loads of both server and client-side ways to bypass that.

I was trying to stop bots and scrappers and people not in the myLiveFriends list adding it to their website. I was hoping it would make loads of pop-ups in programmes running scrappers. I noticed tonight that the unitingrhythms website was doing it on its own, even when fromthat site. It shouldn’t, and the livescript site doesn’t though.

Maybe the easiest and least processor intensive way to handle that is just to give them the info they want as fast as you can

Ah, a CSS dude. Thought I remembered right. Had to check your profile.

How about a css div or something for those? with everything set inline?

I want to allow them to have the data, but with something to let them know where it originates from if not in a list