It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

how to get parameters from a hyperlink using javscript

how to get parameters from a hyperlink using javscript

Postby sundarraj_mca on Sat May 24, 2008 7:16 am

hai developers

i have a problem in my site. i used tabbed panel in my site and when ever i click on a hyperlink in any tab when page gets refreshed default tab is displayed. i found that default value is 0 in JS. i kn ow how to handle it, but i dont know how to get values from a href using javascript

how set a value for a href so that in JS i can get that value using getElemetById method
sundarraj_mca
 
Posts: 22
Joined: Wed May 14, 2008 5:06 am

Postby rangana on Sat May 24, 2008 7:31 am

Code: Select all
window.onload=function()
{var lnks=document.getElementsByTagName('a');
   for(var i=0;i<lnks.length;i++)
   {
   lnks[i].onclick=function()
      {alert(this.href);return false;}
   }
}


This code will alert whatever value is inside the href attribute during onclick. See if it helps ;)
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Postby sundarraj_mca on Sat May 24, 2008 9:08 am

how to know which link is clicked using javscript
sundarraj_mca
 
Posts: 22
Joined: Wed May 14, 2008 5:06 am

Postby rangana on Sat May 24, 2008 9:13 am

What information do you need to show?..and btw, how do we know that the link is clicked?..do you want to alert his chronological order, Example, this is the link 1, this is link2....or you mean something else ;)

I don't get it. I'm confused (nothing new) :roll:
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 6 guests