JavaScript unable to run “canvas” tag and javascript program in aptana studio

Below shown is my HTMLcode :

<!doctype html>
<html lang="en"> 
   <title></title>
   <head>
      <script scr ="myprog.js"> </script>
   </head>
   <body>
      <section id="main">
         <canvas id="canvas" width="600" height="400"></canvas>
      </section>
   </body>
</html>

And my javascript code is as below:

function doFirst(){
   var x=document.getElementById('canvas');
   canvas=x.getContext('2d');
   canvas.strokeRect(10,10,100,200);
}

window.addEventListener("load",doFirst,false);

as per my understanding I'm suppose to get a rectangle of 100*200 in the browser(I'm using firefox browser). But here in my case, after running the above code I'm just getting a blank web page and I'm not getting any errors in the Aptana studio console too. Can anyone help me find out what the problem is?

I tried running a simple javascript program too ,to check if the my aptana studio can run javascript,and the following was the result:

1) when I added a button and tried to call a function using the below code,i got the alert after I clicked the button on the webpage(that is the program worked fine) : <input type="button" value="click me" onClick="alert('hello')/>;

2)But when I tried to run this particular code given below,i didn't get anything on my webpage:

doFunction(){
   alert('hello');
}
window.addEventListener("load",doFirst,false);

document.getElementById("clickMe").onclick = "doFunction()";

3)I made sure that I linked my javascript file with my html using the code: <script src="my prog.js"></script> so the problem is not with the linking I guess.

Kindly please someone help me out... Thank you in advance...

Answer:1

I am loading all website's pages into the main index page, and updating URL display by splitting the href into segments and adding the segments after the main domain name with .hash function, like ...

I am loading all website's pages into the main index page, and updating URL display by splitting the href into segments and adding the segments after the main domain name with .hash function, like ...

my function is as easy as this: function changeColor(color, opacity, obj) { var colors = obj.getElementsByClassName("color_elem"); for (var i = 0; i < colors.length; i++) { ...

my function is as easy as this: function changeColor(color, opacity, obj) { var colors = obj.getElementsByClassName("color_elem"); for (var i = 0; i < colors.length; i++) { ...

I have function in my code, which suppose to gradually decrease the refreshment of the page from 50 sec to 10 if the button is pressed. Here it is: <div id="signin" onclick="pgeReload()"></...

I have function in my code, which suppose to gradually decrease the refreshment of the page from 50 sec to 10 if the button is pressed. Here it is: <div id="signin" onclick="pgeReload()"></...

  1. retain value variable
  2. retain variable value in sas
  3. retain variable value in vba
  4. retain variable value in javascript
  5. retain variable value c#
  6. retain javascript variable value after postback
  7. retain value in global variable
  8. excel vba retain variable value
  9. python retain value of variable
  10. how to retain variable value in java

I want to visualize some timeseries data in the browser with jqplot. My problem is, that the x-axis values overlay and aren't readable. Therefore, the zoom function would be very useful. But it ...

I want to visualize some timeseries data in the browser with jqplot. My problem is, that the x-axis values overlay and aren't readable. Therefore, the zoom function would be very useful. But it ...