[Javascript] capture & redirect URL

Paul Novitski paul at novitskisoftware.com
Fri Jan 6 18:31:43 CST 2006


At 03:46 PM 1/6/2006, Tom Allison wrote:
>I was playing with www.google.com and found in a proxy that I can 
>replace the URL's that come as HTML text ( eg: <a 
>href="http://www.google.com/"> ) but I can't figure out how to 
>replace some of the URL's that I find on the google homepage.
>
>But I'm not capturing all of them.  (probably not a javascript 
>question anymore)
><a id=1a class=q href="/imghp?hl=en&tab=wi" onClick="return qs(this);">
>shows up on the bar with www.google.com/ instead of my 'munged' address.


Tom,

href="/imghp?hl=en&tab=wi" is a relative URI.  The browser 
automatically completes it by prefixing the current domain -- either 
the domain where the page is located or one set by a BASE tag.  If 
you're going to modify URIs on the fly, you may have to explicitly 
prefix a domain name to prevent the browser from correctly completing 
a relative URL with what it knows to be the correct domain.

For more details, read the W3C HTML 4.01 specification on links:
http://www.w3.org/TR/html4/struct/links.html

If you find a function name used in place of a URI, e.g.

         href="doSomething();"
or
         href="javascript: doSomething();"

then that's a direct reference to a client-side script function 
which, in order to work, must be present either in the HTML page 
itself or in an external script file linked with a SCRIPT 
tag.  Client-side function references aren't considered to be URIs as 
far as I know.

If you'll describe just what it is you're attempting to accomplish, 
it would help us give you more specific advice.  If you're right and 
your question doesn't bear on javascript, there are other good web 
development listserves where you can pose your questions in good conscience.

Paul 




More information about the Javascript mailing list