Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Ok, I just wanted to check if you where looking for a free freelancer.
Sorry, me just being paranoid.
For that, the most DOM compliant way is to add an event that will scan every tags "a" in the page, and rewrite their href. No need to drop them.
HTML Code:
<html>
<head>
<title>dfg</title>
</head>
<body>
<script type="text/javascript">
function handleUri(){
var ary=document.getElementsByTagName('a');
var aryTmp = new Array();
var isbn=null;
var i=0;
for(i=0;i<ary.length;i++){
if(ary[i].href.indexOf(':isbn:')!=-1){
//This is an isbn url
aryTmp=ary[i].href.split(":");
isbn = aryTmp[2];
ary[i].setAttribute('href','http://www.amazon.com/dp/'+isbn);
}
}
}
try{
window.addEventListener('load',handleUri,true);
}
catch(r){
window.attachEvent('onload',handleUri);
}
</script>
<a href="urn:isbn:<isbn1>">Book</a><br/>
<a href="urn:isbn:<isbn2>">Book</a><br/>
<a href="urn:isbn:<isbn3>">Book</a><br/>
<a href="urn:isbn:<isbn4>">Book</a><br/>
<a href="http://www.google.com">Not isbn!</a><br/>
</body>
</html>
Note that here, I consider that the href to handle are always containing ":isbn:", it ignores every other links
__________________
Only a biker knows why a dog sticks his head out the window.
Last edited by tripy; 08-13-2007 at 04:41 PM..
|