Forum Moderators: not2easy
but I still need a way to alert the user that they are leaving my site can I do this in a javascript function?
A client recently had me build a widget like this--over my strong objections--and I fully expect the client to notify me that they'd rather not use the script anymore after a couple of months' worth of user complaints. Don't do it.
Having said that, it's easy enough. You're just going to have to do the following (in pseudo-code):
Again though I think this is a very bad method for notifying the user of something that they, in all probability, already know. A far better method would be to use the same method (collecting together and checking the href attributes of every link) do something like what wikipedia does with their external links--use css to display a little icon beside the link text.
-b