Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
February 06, 2012, 11:41:31 PM

Pages: [1]   Go Down
  Print  
Author Topic: Javascript block enter key  (Read 4013 times)
Helpmeplz
Newbie
*
Offline Offline

Posts: 2


« on: July 24, 2005, 05:58:38 AM »

I am making a site with lots of javascript alerts. The only problem is I want my visitors to read them and they can easily skip them all by holding down enter. I've searched  the internet for a way but all that there is is blocking it in forms and i am too new with javascript to work it out.

All i wnt the program to do is either block enter totally(most preferable)
Or  display an alert saying "What you trying" or similar then continue on where it left off.
 
The closest (i think) i've got is:
if (keypress = "13"){
alert("What you trying")
}
or
if (keypress == "13"){
alert("What you trying")
}
but neither has the desired affect.
The former just displays an what you trying at the start  and doesn't respond to enter.
The latter just gives a blank screen, but strangely, no  error message

Plz help me

Helpmeplz
Logged
Rowan
hamburglar
Über Jedi
*****
Offline Offline

Posts: 1919


I used to be Human....2.0b


WWW
« Reply #1 on: July 30, 2005, 05:48:27 PM »

if (keypress = "13")

is not correct, it will always be true because the value "13" will always be able to be assigned to keypress (i think thats how it works)

the second one is closest because your using ==.
this page has almost exactly what your after:
http://dev.kanngard.net/Permalinks/ID_20050426091851.html

just change to this part
Code:
if(key=="13")
{
 alert("your thign here")
}
« Last Edit: July 30, 2005, 05:50:36 PM by human2.0b » Logged

Helpmeplz
Newbie
*
Offline Offline

Posts: 2


« Reply #2 on: August 05, 2005, 01:53:16 AM »

Thx v much. Its a lot closer than what i had but not exactly what i was looking 4. This code only works when alerts arent running. The prob is i wnt the message 2 b displayed while  the alerts are running. For example:

Code:
alert("1")
alert("2") //enter key is pressed here
alert("message saying dont press enter")
alert("3") //resumes where it left off
Obviously this code is going 2 display 4 alerts but it demostrates what i wnt 2 happen.
Would it hlp if i posted a link to the site im working on? 

Thx

HlpmePlz


Btw, any1 know the ascii code 4 ctrl?
« Last Edit: August 05, 2005, 02:26:12 AM by Helpmeplz » Logged
Pages: [1]   Go Up
  Print  
 
Jump to: