Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Executing function when <link> navigation element is used

Reply
Thread Tools

Executing function when <link> navigation element is used

 
 
Spartanicus
Guest
Posts: n/a
 
      11-16-2006
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
 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      11-16-2006
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/
 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      11-16-2006
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
 
Reply With Quote
 
Spartanicus
Guest
Posts: n/a
 
      11-17-2006
Randy Webb <(E-Mail Removed)> wrote:

>> 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
 
Reply With Quote
 
Spartanicus
Guest
Posts: n/a
 
      11-17-2006
ASM <(E-Mail Removed)> wrote:

>> 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
 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      11-17-2006
Spartanicus a écrit :
> ASM <(E-Mail Removed)> wrote:
>
>>> 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
 
Reply With Quote
 
Spartanicus
Guest
Posts: n/a
 
      11-17-2006
ASM <(E-Mail Removed)> wrote:

>> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
Disable the navigation buttons for IE navigation toolbar Laurahn ASP .Net 3 02-06-2007 04:17 AM
Can be multiple instances of element used as the root element? VK XML 8 10-31-2006 06:51 PM
Executing a mouseover associated with another element Vinayak Javascript 2 07-21-2006 02:42 PM
body onload executing after script element? yawnmoth Javascript 7 07-17-2006 10:36 PM



Advertisments