| View previous topic :: View next topic |
| Author |
Message |
autos06
Joined: 13 May 2006 Posts: 123 Location: New York
|
G'day.
From Javascript, how do I follow a link?
Say I can grab the link using document.getElementById() how do I click on it? |
| |
|
|
|
|
optomeb
Joined: 19 May 2006 Posts: 113
|
| .click() |
| |
|
|
autos06
Joined: 13 May 2006 Posts: 123 Location: New York
|
| Excellent |
| |
|
|
kadamat
Joined: 01 Jun 2006 Posts: 88
|
Ikopar, are you sure?
I'm using firebug, and I can grab the element, but it doesn't have a click() method |
| |
|
|
Ikopar
Joined: 26 May 2006 Posts: 168
|
Well it depends on the UA
The other option is to get the location and manually change to it |
| |
|
|
kadamat
Joined: 01 Jun 2006 Posts: 88
|
Document.getElementsByTagName('a')[0].click is undefined.
But that returns <a href="/home/"
Using firefox
That's the only UA i need to support |
| |
|
|
Ikopar
Joined: 26 May 2006 Posts: 168
|
| So location=el.href; job done |
| |
|
|
kadamat
Joined: 01 Jun 2006 Posts: 88
|
| Ikopar: but it's a relative url, does that work? |
| |
|
|
Ikopar
Joined: 26 May 2006 Posts: 168
|
Sure
It won't with base href in there
But otherwise |
| |
|
|
kadamat
Joined: 01 Jun 2006 Posts: 88
|
| How would I go about getting the base href? |
| |
|
|
| Page 1 of 2 |
Goto page 1, 2 Next |
|