faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

63 of 72 people (88%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

how can i call two functions at same event?

Apr 7th, 2008 23:09
ha mo, Colin Fraser, rashi kulshrestha,


One way is to try : 
function doThisFirst() {
  alert("Changing current location")
}
function doThisNext()  {
   location.href="myotherpage.html"
}
function doThese() {
   doThisFirst()
   doThisNext()
}
<a href="javascript:null()" onClick="doThese()"><img src="image.jpg"></a>
You can have as many events as you like here, but it can get a little
messy. 
Alternatively you can have :
<a href="javascript:null()" onClick="doThisFirst();doThisNext()"><img
src="image.jpg"></a>
The semi-colon separates the function calls.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com