Jump to content

martinvie

Members
  • Posts

    2
  • Joined

  • Last visited

martinvie's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hi all,Let's say I have a lot of buttons with onclick events. It seems to me I have 4 main options to code the event handling:-------------------#1:<head> <script> function doSomething(){ doThis; doThat; doMore; } </script></head><body> <input type = "button" onClick = "doSomething()"></body>--------------------#2:<head> <script> window.onload = function(){ document.getElementById("idKnopf").onclick = doSomething; } function doSomething(){ doThis; doThat; doMore; } </script></head><body> <input type = "button" id="idKnopf"></body>--------------------#3:<head> <script> window.onload = function(){ document.getElementById("idKnopf").onclick = doSomething; function doSomething(){ doThis; doThat; doMore; } } </script></head><body> <input type = "button" id="idKnopf"></body>--------------------#4:<head> <script> window.onload = function(){ document.getElementById("idKnopf").onclick = function(){ doThis; doThat; doMore; } } </script></head><body> <input type = "button" id="idKnopf"></body>--------------------Is there a difference in Performance?Is there a difference between #2 and #3?Will the complete function be written into the object immediately in all 4 cases, like it should be expected in #4, or wil #2 or #3 just write a reference into the object and read the function only when it is called, that is when the event is triggered?Could it be that #2 or #3 will load faster, but will take slightly longer to execute the function when the body is clicked, or doesn't it make a difference at all?I am writing a rather longish HTML application and I want to reduce the loading time as much as possible.Every little hint will be appreciatedCheersMartin
  2. Or this:<script>var windowReference;function go(){windowReference = window.open('newpage.html','linkname','height=400, width=700,scrollbars=yes');windowReference.focus();}</script><body><A HREF="java script:go()">Open page</a></body>
×
×
  • Create New...