Saving mouse click coordinates into a file
Dear everyone,
First of all, I am a newbie to html and javascript (ie. never used them before) so please bear with me.
I am trying to capture the x and y coordinate of the left mouse click and save them to a file. While browsing the internet i found the following code,
<script type="text/javascript">
document.onmousedown = function(e){
var coordX = (e && e.pageX)? e.pageX : event.x;
var coordY = (e && e.pageY)? e.pageY : event.y;
alert('x = '+coordX+'\ny = '+coordY);
}
</script>
This however does not serve my purpose:
1- It does not save the x and y coordinates into a file but rather displays them within a dialog box.
2- User scrolling is ignored. I want to capture the x and y coordinates in relation to the top right corner of the document. (that is, the invisible parts of the screen once the user scrolls must be taken into consideration)
Can someone please help ?
[985 byte] By [
llp00na] at [2007-11-19 21:10:25]

# 2 Re: Saving mouse click coordinates into a file
You cannot use a client-side script to save to a hard disk. If you pass these variables on to PHP or ASP then it can be saved to a file.
Wow, thats terrible news for me then. I dont even know how to use html and javascript. Now i need to do it PHP/ASP way !!!
And yes, i have made sure that Javascript does not offer native file handling capabilities. But i have read that there is a way to do it using Windows Script Host, which i know nothing about.
Do you have any idea how this might work ? else or whats the way to go using PHP / ASP.
I am gratefull
# 4 Re: Saving mouse click coordinates into a file
Using Windows Scripting Host is known as VBScript. This will require a script notification message every time and only work on IE.
I will be using IE. So it is possible to do that using VBScript !!! Do i need any servers installed. Or can i just embed the code into an html file ?
# 5 Re: Saving mouse click coordinates into a file
It will still have to be server-side. A web browser cannot write to the local machine viewing the page.
If you are interested server side, take a look at this ( http://computerperformance.co.uk/vbscript/vbscript_file_opentextfile.htm).