2 Replies - 436 Views - Last Post: 11 September 2012 - 04:54 AM

#1 StefanOnRails  Icon User is offline

  • D.I.C Head

Reputation: 35
  • View blog
  • Posts: 105
  • Joined: 31-July 12

why put "javascript:" before calling a function?

Posted 11 September 2012 - 03:37 AM

Hi,

It might be a newbie question, but why some people use javascript: before they call a function?
<!-- E.g. -->
<input name="submit" type="button" onclick="javascript:submit_form();" />
Is it some old javascript syntax? I think is used to define the language in which the function is written, but why is important?
Is This A Good Question/Topic? 0
  • +

Replies To: why put "javascript:" before calling a function?

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3712
  • View blog
  • Posts: 5,964
  • Joined: 08-June 10

Re: why put "javascript:" before calling a function?

Posted 11 September 2012 - 04:03 AM

Yea, it's meant to define the script language used. For instance, some old IE-only sites would use VBscript instead of Javascript, and then you would do:
<input onclick="vbscript:form_onsubmit()">



All browsers will default to Javascript, though, so if that is what you're using you don't have to define the script name.

Of course, the best thing to do is not use the HTML event attributes at all, and bind events in Javascript code instead.
Was This Post Helpful? 1
  • +
  • -

#3 StefanOnRails  Icon User is offline

  • D.I.C Head

Reputation: 35
  • View blog
  • Posts: 105
  • Joined: 31-July 12

Re: why put "javascript:" before calling a function?

Posted 11 September 2012 - 04:54 AM

Thanks for explanation :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1