Difference between revisions of "Javascript"

From ThorstensHome
Jump to: navigation, search
(Created page with "To quickly debug javascript code there is the '''alert''' function. However this requires you to click for every information you get. A quicker way is to write your informatio...")
 
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
 +
= Debugging Javascript =
 
To quickly debug javascript code there is the '''alert''' function. However this requires you to click for every information you get. A quicker way is to write your information directly onto the site. For example if your window gets resized, output its new size like this:
 
To quickly debug javascript code there is the '''alert''' function. However this requires you to click for every information you get. A quicker way is to write your information directly onto the site. For example if your window gets resized, output its new size like this:
  
Line 15: Line 16:
 
</pre>
 
</pre>
  
 +
The result will be like this:
 
<html>
 
<html>
 
<script language=javascript>
 
<script language=javascript>
Line 26: Line 28:
 
</div>
 
</div>
 
</html>
 
</html>
 +
 +
[[Category:Programming]]

Latest revision as of 11:23, 17 February 2015

Debugging Javascript

To quickly debug javascript code there is the alert function. However this requires you to click for every information you get. A quicker way is to write your information directly onto the site. For example if your window gets resized, output its new size like this:

<html>
<script language=javascript>
window.onresize = function(event) 
{
  document.getElementById("debug").innerHTML=window.innerWidth+"x"+window.innerHeight;
}
</script>
<div id="debug">
  Resize your Window to start.
</div>
</html>

The result will be like this:

Resize your Window to start.