Spartanicus a écrit :
ASM <st************ *********@wanad oo.fr.invalidwr ote:
>>I'd like to execute a function when a <link rel="next" href="foo.htm">
type element is used. Although the "onclick" handler is allowed on the
element, presumably because the functionality of the element is made
available through a browser provided navbar the function doesn't execute
when using the element.
onload = function() {
var L = document.getEle mentsByTagName( 'link');
var ok = false;
for(var i=0; i<L.length; i++)
if(L[i].href && L[i].href.indexOf(' foo.htm')>0 &&
L[i].rel && L[i].rel=='next') ok=true;
if(ok) alert('right link');
}
By "used" I meant "clicked", not present in the code.
How do you expect to click something not present ?
<html>
<script type="text/javascript">
onload = function() {
var L = document.getEle mentsByTagName( 'A');
for(var i=0; i<L.length; i++)
if(L[i].href && L[i].href.indexOf(' foo.htm')>0 &&
L[i].rel && L[i].rel=='next')
L[i].onclick = function() {
alert('Gasp! I am discovered');
return false;}
}
</script>
<a href="#">test 1</a>
<a rel="next" href="foo.htm"> foo</a>
<a href="foo2.htm" >test 1</a>
</html>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date