Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Javascript Events Not Working For Ie
hippiman
post Aug 17 2007, 06:24 PM
Post #1


Premium Member
********

Group: Members
Posts: 150
Joined: 9-April 07
From: Nebraska
Member No.: 41,301



I just made this little html file and I used javascript to show which arrows you're pressing. It just says the key code, but only for the arrows, so it will say "37, 38, 39, 40" if you're pushing all the arrows. When you let go of the arrows, it won't show that value.
It works perfectly in Firefox, but I can't get it to run in Internet Explorer. The little notification bar down in the bottom left of the window says there's an error, and it just sits there.
All I used was a function for onKeyDown and onKeyUp on the body, and every 10 milliseconds it shows what keys you have pushed.

Here is a link to what I have so far: Javascript Thing

If you have Firefox, all you have to do is click on the page anywhere, and start pressing the arrows, and it should work. But in IE, all it does is display all the numbers, no matter what keys you're pushing. You can look at the page source to see what's going on, but the only functions you should have to look at are dispMultiKeys(), setKeyDown(e), and setKeyUp(e). All the other functions are just because I was messing around trying to figure stuff out.

I did the "saved from internet" thing at the top so IE wouldn't say the thing about ActiveX controls.

The "e = e || window.event; code = e.keyCode || e.which;" is supposed to make the key events work for most browsers.
dispMultiKeys() happens every 10 milliseconds, and it just displays what keys you're pressing. I just used setInterval.
I declared 2 arrays at the beginning, and the keysPressed array is just to say what keys are down, and the other one is just supposed to help declare it, because it wouldn't work using keysPressed[37, 38, 39, 40] and looping through that setting it all to false.

I don't really use IE that much, but I just want all my stuff to work for everyone.
If anyone can figure out what I'm doing wrong so it doesn't work with IE, I'd appreciate it. Thanks in advance!
Go to the top of the page
 
+Quote Post
truefusion
post Aug 18 2007, 01:16 AM
Post #2


Ephesians 6:10-17
Group Icon

Group: [MODERATOR]
Posts: 1,994
Joined: 22-June 05
From: somewhere... Where am i?
Member No.: 8,528
myCENT:72.96



Have you tried removing the two forward slashes in:
HTML
onload="KeyTester=setInterval('dispMultiKeys()', 100);//Frames=setInterval('dispDimensions()', 1000);"
?
Also, check to see if your Internet Explorer supports the canvas element.
Go to the top of the page
 
+Quote Post
hippiman
post Sep 22 2007, 06:22 PM
Post #3


Premium Member
********

Group: Members
Posts: 150
Joined: 9-April 07
From: Nebraska
Member No.: 41,301



The forward slashes are just to make the line a comment. It shouldn't have any problem with that in any browser that's javascript compatible.

And I've also found out that I can't get anything with loops or events in javascript to work with IE. It says something about ActiveX controls, then it just goes through the loop once. I'm just using a 'for' loop, which works perfectly in FF.

I think it might be having problems with the "document" element. There was one page that said something about using "document.all", but that didn't help at all, either. It might be something to do with my settings in IE, too.

I guess I'll just have it say that it only works in FF or something, whenever someone with IE tries to view the page. Oh, well.
Go to the top of the page
 
+Quote Post
reconraiders
post Sep 22 2007, 07:03 PM
Post #4


Super Member
*********

Group: Members
Posts: 221
Joined: 6-June 07
Member No.: 44,288



you should try making your html complete. Add the <html> tags and the <head>. Add a doctype too so that the browser knows what the hell it's supposed to do. If you do all that and make your page standards compliant it might work in more browsers.
Go to the top of the page
 
+Quote Post
galexcd
post Sep 28 2007, 06:39 PM
Post #5


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
***********

Group: [HOSTED]
Posts: 1,206
Joined: 25-September 05
From: Los Angeles, California
Member No.: 12,251
myCENT:25.62



QUOTE(reconraiders @ Sep 22 2007, 12:03 PM) *
you should try making your html complete. Add the <html> tags and the <head>. Add a doctype too so that the browser knows what the hell it's supposed to do. If you do all that and make your page standards compliant it might work in more browsers.


Most recent popular browsers that people use can work without the heml tag, head tag or doc id. Perhaps if you are testing it on an older browser that might pose some problems but this wouldn't fix anything. I am quite curious of the comment in your onload event. I'm not quite sure all browsers like comments in there. Try removing that comment, i mean since you have it commented out it shouldn't be necessary right?
Go to the top of the page
 
+Quote Post
reconraiders
post Sep 28 2007, 09:11 PM
Post #6


Super Member
*********

Group: Members
Posts: 221
Joined: 6-June 07
Member No.: 44,288



Nice job! Account suspended... So much for this topic.
Go to the top of the page
 
+Quote Post
hippiman
post Sep 28 2007, 09:39 PM
Post #7


Premium Member
********

Group: Members
Posts: 150
Joined: 9-April 07
From: Nebraska
Member No.: 41,301



Not that this really matters, but my account should be back up in a couple of hours, according to the thing.

I probably should have just copied my HTML file and posted it as part of this topic, though, because I'm kind of slow at posting, and I've had this happen before.

Thanks for the comments, though. I need to check some of that out when my account gets back up.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Javascript Slideshow Tutorial(7)
  2. Javascript Close Window(15)
  3. One Click Copy And Paste To Clipboard(5)
  4. Adding Rows & Columns In Html Table Using Javascript(1)
  5. I'm Making My Own Javascript Only Rpg :d(7)
  6. What's The Relationship Between Javascript And Java(7)
  7. Javascript : No Right Click Script !@(12)
  8. Hiding <div> Boxes With Javascript(8)
  9. Highlight A Word In Javascript. Help!(2)
  10. How Do You Make A Javascript Calculator?(11)
  11. Help With Javascript Calculator Returning "nan"(2)
  12. Great Javascript Script Source(2)
  13. Web Applications: J2ee Or Javascript/css/html(1)
  14. Opera Browser + Javascript + Embeded Sound(0)
  15. Javascript - What's Your Browser?(3)
  1. I`m New To Javascript.(5)
  2. Special Wii Javascript(2)
  3. Javascript Error(2)
  4. Is It Possible To Create A Web Based Mmo In Javascript?(4)
  5. Capturing Username Of Computer(3)
  6. Javascript Object Node Referencing Help(5)
  7. Flash And Javascript Interaction(1)
  8. Document.write & Noscript Questions (javascript)(2)
  9. Java Vs Javascript(11)
  10. Adjusting Rows/cols Of Frames In Frameset Using Javascript Is Not Working In Firefox 3 Is Not Working(4)
  11. Need Help With Javascript Drag And Drop Script(2)
  12. Re-learning Javascript(3)
  13. Javascript Game(6)


 



-