Executing function when <link> navigation element is used

S

Spartanicus

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?
 
R

Randy Webb

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()"
 
A

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.href && L.href.indexOf('foo.htm')>0 &&
L.rel && L.rel=='next') ok=true;
if(ok) alert('right link');
}
 
S

Spartanicus

Randy Webb said:
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.
 
S

Spartanicus

ASM said:
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.href && L.href.indexOf('foo.htm')>0 &&
L.rel && L.rel=='next') ok=true;
if(ok) alert('right link');
}


By "used" I meant "clicked", not present in the code.
 
A

ASM

Spartanicus a écrit :
ASM said:
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.href && L.href.indexOf('foo.htm')>0 &&
L.rel && L.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.href && L.href.indexOf('foo.htm')>0 &&
L.rel && L.rel=='next')
L.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>
 
S

Spartanicus

ASM said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top