Jump to content

LucasMars123

Members
  • Posts

    10
  • Joined

  • Last visited

Posts posted by LucasMars123

  1. Can someone please give me some example code so I can link a webpage to another using javascript? This is my code at the moment:- document.onkeydown = function(e) { e = e || window.event; // because of Internet Explorer k = e.which || e.charCode || e.keyCode; // because of browser differences... if (k == 49 && !e.altKey && !e.ctrlKey && !e.shiftKey) { string.link(link.html) } else { return true; } return false; } This won't link me to the other link when "1" on the keyboard is pressed... Please Help!

  2. <html><body><canvas id="button" onmouseover="myfunction()" onmouseout="myfunction2()" width="100"height="100"></canvas><script> var c=document.getElementById("button");var ctx=c.getContext("2d");function myFunction(){ctx.fillStyle="#ff0000";}function myFunction2(){ctx.fillStyle="red";}</script></body></html>

    Pleaseeee can someone tell me what im doing wrong. all I want is a box that changes color when the mouse goes over it.

    How about this:- <html><head><title>Title</title></head><body><style>div{width:111;height:237;background:#003366;}div:hover{background:#4D7094;}</style><div><p> </p></div></body></html>And Then Use http://www.w3schools.com/tags/ref_colorpicker.asp To Change The Colour
  3. Also i've put the random method as global, because if it is inside the function every time you press Submit, it will generate new number. Correct me if im wrong. :)
    How about, when you get the correct answer it will re-generate the answer if (a==x) { confirm("Gratz, you've entered the right number"); a=Math.floor((Math.random())*100+1);} [EDIT]Would that work? You are not wrong, but that is what I would do :)[/EDIT]
    • Like 1
  4. <html> <head> <title> JS studing</title> </head> <body onload="start()"> <b><p id="show">Please enter a number between 1-100</p></b> <input id="test" type="number"> <button type="button" onclick="test1()">Submit</button> <p id="result"></p> <script> function start() { var n=Math.floor((Math.random())*100+1); var d=document.getElementById('test').value; } function test1() { if (n==d) { alert("Well Done! You Have Guessed The Number!") } else { alert("You Have Guessed The Wrong Number. "+d+" Is Not Correct.") } } </script> </body></html> Hopefully this helps.

    • Like 1
  5. I am having problems using the "<canvas>" tag as I am using HTML code from your website. http://www.w3schools...tml5_canvas.asp - Canvas Coordinates. Now, I have a piece of code that I have to find the "<canvas>" tag to add. In the code, I found out that a div creates the canvas. But how would I add an image that bounces across the screen when the mouse is over the canvas. I already have the co-ordinates of the mouse and the image inserted. I have attached the .html file and an image a.png. This should create an object and show you the co-ordinates of the mouse when it is over the canvas. And when it is not, it does not show any co-ordinates and shows a heading of PAUSED.post-145722-0-12618800-1367140040.pngindex.htmlMany Thanks,[EDIT] Please could someone reply and post some code for this problem. I am only new to HTML. There is Javascript in there but that was in the canvas code here:-http://www.w3schools.com/html/html5_canvas.asp [/EDIT]Additional:-This doen't work in Internet Explorer 10 - well it didn't when I tried.

×
×
  • Create New...