Link to home
Start Free TrialLog in
Avatar of blue-genie
blue-genieFlag for South Africa

asked on

have an onload which simulates the click of an a href

i have an ahref which has some java/javascript code that executes a search function, what i want to do is when that page loads call that method as well, i don't want to replicate that method, i want to simulate the link being clicked, can this be done and how do i go about doing it?

ta.
blu
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

In the body tag put this:
<body onLoad="theLink.click()">


...and immediately after the link put this script statement:
<script>theLink=document.links[document.links.length-1];</script>

ASKER CERTIFIED SOLUTION
Avatar of shaggy_the_sheep
shaggy_the_sheep

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of blue-genie

ASKER

Thanks Richard, U Rock!!!!
Works a charm, we're not too concerned about cross -browser stuff for now, just need it to work in IE/
blu.
Avatar of shaggy_the_sheep
shaggy_the_sheep

Great, glad i could help

Richard