469,918 Members | 2,043 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,918 developers. It's quick & easy.

Executing function when <link> navigation element is used

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.

Anyone know if this is possible?

--
Spartanicus
Nov 16 '06 #1
6 1368
Spartanicus said the following on 11/16/2006 3:40 PM:
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.

Anyone know if this is possible?
Never done anything with a navbar but you might try setting the
href="javascript:functionName()"

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 16 '06 #2
ASM
Spartanicus a écrit :
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.getElementsByTagName('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');
}

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 16 '06 #3
Randy Webb <Hi************@aol.comwrote:
>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.

Anyone know if this is possible?

Never done anything with a navbar but you might try setting the
href="javascript:functionName()"
I need to preserve the href attribute value. I use JS to rewrite that
value, but I don't want to make the feature JS dependant.

--
Spartanicus
Nov 17 '06 #4
ASM <st*********************@wanadoo.fr.invalidwrote :
>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.getElementsByTagName('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.

--
Spartanicus
Nov 17 '06 #5
ASM
Spartanicus a écrit :
ASM <st*********************@wanadoo.fr.invalidwrote :
>>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.getElementsByTagName('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.getElementsByTagName('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
Nov 17 '06 #6
ASM <st*********************@wanadoo.fr.invalidwrote :
>By "used" I meant "clicked", not present in the code.

How do you expect to click something not present ?
That is the question I was asking. I'm not sure what phrase to use, not
"used", not "clicked", "activated" would probably have been better.

I am now experimenting with Randy's suggestion after I realised that I
could use <link rel="next" href="foo.htm"in the HTML and then rewrite
the href value to "javascript:functionName()" with JS.

--
Spartanicus
Nov 17 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Francesco Moi | last post: by
2 posts views Thread by Hernán Castelo | last post: by
2 posts views Thread by Alex Maghen | last post: by
17 posts views Thread by The Numerator | last post: by
9 posts views Thread by Arancaytar | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.