Jump to content

ReGA

Members
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

0 Neutral

About ReGA

  • Rank
    Newbie

Previous Fields

  • Languages
    HTML (DOM), Javascript, PHP, MySQL

Profile Information

  • Location
    Belgium
  • Interests
    Minecraft, Programming
  1. Just use the onload event for the body element to show the box.Then it won't be called when clicking the text "CLICK HERE", but it will be called when the page loads.
  2. If you limit the number of 'checks', it will not have much effect on your friend's server. Maybe you could make something that only checks this every 5-10 minutes, and showssomething like: "Last check: 7 min ago" Just an idea
  3. Hey, I googled a little and found this (I didn't make this):http://jsbin.com/owawuq/2/edit Try to change some styles, and you'll be able to get your wanted gray background.
  4. Odd... Thanks for your replies anyway, guys.
  5. You will have to add an event to your video tag: onended. Then, you need a function that can be called from the video element. Example: <script> function redirect() { document.location="index_2.html"; }</script> <video src="index_vid.WEBM" onended="redirect()">Your browser cannot display the video element.</video> When the video has ended, the function redirect() will be called.In this function, we change the client's location. I hope this helps.
  6. Yes, the event onkeydown gets called repeatedly if you hold a key.I had a similar problem in firefox. But this only happens after a certain delay. You can avoid this by using an onkeyup event: <html><head><script>var hasPressed=false;function myFunction(e,keyDown) { if (hasPressed && keyDown) return; hasPressed=keyDown; // Code}</script></head><body><input type="text" onkeydown="myFunction(event,true)" onkeyup="myFunction(event,false)"></body></html>
  7. Hmmm... Yeah, tutorials are a good idea. But here are some examples any way: If, else: yourName=prompt("Please enter your full name:","John Johnson");if (yourName=="John Johnson") { alert("You used the standard name!");}else { if (yourName.length<=5) alert("Your name is a little short..."); else if (yourName.length>5 && yourName.length<=25) alert("I like your name..."); else { alert("Your name is too long."); }} Or this: yourName=prompt("Please enter your full name:","John Johnson");if (yourName=="John Johnson") { alert("You used the standard name!");}else if (yourName.length<=5) alert("Your name is a little short...");else if (yourName.length>5 && yourName.length<=25) alert("I like your name...");else { alert("Your name is too long.");} While/ Do-while: name=prompt("Enter a name (maximum 30 characters):");if (name) { while (name.length>30) { name=prompt("Enter a name (maximum 30 characters).",name); }} Or this: do { name=prompt("Enter a name (maximum 30 characters):");} while(name && name.length>30);
  8. I'm using this function to detect whether a key is being hold: var keyDown=new Array(false,false,false,false,false,false); function keys(e,isDown) {keynum=-1;if (e.which) { keynum=e.which;}else if (window.event) { keynum=e.keyCode;}if (isDown && keynum==32) alert("Spacebar!"); // Test 1if (keynum==38) { // Arrow-up keyDown[0]=isDown;}else if (keynum==39) { // Arrow-right keyDown[1]=isDown;}else if (keynum==40) { // Arrow-down keyDown[2]=isDown;}else if (keynum==37) { // Arrow-left keyDown[3]=isDown;}else if (keynum==32) { // Spacebar keyDown[4]=isDown; if (isDown) alert("Spacebar!"); // Test 2}else if (keynum==80) { // P-key keyDown[5]=isDown;}} The function is called in the body-ellement: <body onkeydown="keys(event,true)" onkeyup="keys(event,false)"><!-- Body contents... --></body> Like you can see, when a button is pressed (or released) this is stored in the array. Thismakes it possible for functions to see if a key is being hold at any time (yes, maybe there are other ways to do this). But this combinations do not work (push the keys in the order I give them):1) Press the right and down-arrow;2) Press the spacebar; On my computer the spacebar is not detected, when trying this combination. This combination doesn't work either:1) Press the left and up-arrow;2) Press the spacebar; I really want the spacebar to work! Even the alert boxes do not show up when trying this.I tried this in Firefox en Chrome. Both browsers do not detect the spacebar when pressed. Is there something wrong with the script, or is it a javascript bug? Thanks in advance!
×
×
  • Create New...