Jump to content

HTML href


Guest ulatif

Recommended Posts

I think its a common problem that with time the links to external websites break when they change their filenames/directory structure etc, and one ends up getting an error message.How about modifying the <a> tag and instead of 1 href, we have 2... where the other acts as a back up, so that if the first link breaks / fails you are redirected to the second one instead of getting an error messageThis way, e.g. if your page links to a specific seciton within a site which has changed, instead of an error message you can be taken to the home page of that website, or an error page on your own website with a message to user, in a nice formatted text rather the standard error page of your browser!!!!??

Link to comment
Share on other sites

Create the page that you want as your "error" page. If you would like, set a meta that automatically sends the user to your index in 0 seconds. After creating the page, edit the .htaccess file to your substitutions. Then whenever you get a 404, or a 500, or whatever, you'll be taken to the index. :)

Link to comment
Share on other sites

What I understand you to say is that you basically want to sniff out an external (out of domain) link before you go there to see if its valid. If it is, then let the link behave accordingly, if not, you want it to redirect back to a page in your domain (your site). And, you'd like all this assigned to another attribute (i.e. alturl="http://www.w3wschools.com").First, that request would have to go through the W3C. Irregardless, the nature of XHTML will not be able to do that without the help of some other language.However, technically speaking, you can do this with Cold Fusion - and I imagine with any other scripting language (asp, php, jsp). I've done something similar to this. I've coded some javascript that grabs any link on a page when it's clicked. The script checks the url (against a list of domains) and determines whether to launch the link in a new window or capture the link but send the visitor to a "you're leaving this site, we don't control the content" disclaimer before being redirected to the intended site. No, if you take that application one step further, when I check the url against my list of links, I could fetch the URL and if I get anything but a "20 OK" message from the server, I could send the user wherever I want - to some page on your site in according to your description.Having said all that, do you have access to or knowledge of any of the before mentioned scripting languages?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...