W
Weston C
I'm trying to get the href attribute from the base tag in the document
head. The following does not seem to work... any ideas what I'm doing
wrong?
if(!(document.getElementsByTagName) ||
!(basehrefs = document.getElementsByTagName('base')) ||
!(basehrefs.length) || !(basehrefs.length > 0) ||
!(basehrefs[0].getAttribute) ||
!(basehref = basehrefs[0].getAttribute('href')) )
basehref = '';
This is essentially a very cautious version of:
basehref = doument.getElementsByTagName('base')[0].getAttribute('href')
The big hairy if just provides checks to make sure everything can be
done and provide a contingency if it doesn't...
head. The following does not seem to work... any ideas what I'm doing
wrong?
if(!(document.getElementsByTagName) ||
!(basehrefs = document.getElementsByTagName('base')) ||
!(basehrefs.length) || !(basehrefs.length > 0) ||
!(basehrefs[0].getAttribute) ||
!(basehref = basehrefs[0].getAttribute('href')) )
basehref = '';
This is essentially a very cautious version of:
basehref = doument.getElementsByTagName('base')[0].getAttribute('href')
The big hairy if just provides checks to make sure everything can be
done and provide a contingency if it doesn't...