943,714 Members | Top Members by Rank

Ad:
Jan 4th, 2009
0

Execute external files via event handlers

Expand Post »
Hello to everyone and Happy New Year.
Is it possible to execute external files via event handlers??
I want from an HTML (including JavaScript) web page to execute external files via event handlers.
What I actually want to do is to execute in the background some php files (and do not display anything in the web browser - not even refresh the web page I have loaded).
I've created some forms like the following:
<FORM method="post" action="http://localhost/phpfile1.php?param1=5&param2=0" >
and the input as follows:
<INPUT type="submit" value="Submit1" name="Submit php" onMouseOut="if (navigator.appName=='Microsoft Internet Explorer') document.execCommand('Stop'); else window.stop();">

With the onMouseOut event handler I successfully stop the efforts of the web browser to show the results of the php execution. This is what I want from this event handler.
I also want to have an event handler to start the execution of phpfile1.php.
The reason is I want the onMouseDown to start the php file and the onMouseUp to stop it.
In this way I can achieve that the web browser does not turn away from showing the html page I want, and at the same time execute the php files I want.

Anyone can help me please?
If you did not understand very well what I'm looking for, then please check the following link:
http://www.daniweb.com/forums/post770505.html

Is there any other suitable way to achieve my aim?

Thank you for your time.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kostas Theof is offline Offline
9 posts
since Jan 2009
Jan 4th, 2009
0

Re: Execute external files via event handlers

I check the window.open method that opens a url in a different window.
This would be ideal if I could just execute the php file without opening a window at all.
I also check the AJAX object XMLHttpRequest.
I hope this will execute the php file and not just open it with a "secret"-hidden text reader (like notepad, gedit etc).

Does anyone have any suggestions?

K T
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kostas Theof is offline Offline
9 posts
since Jan 2009
Jan 4th, 2009
0

Re: Execute external files via event handlers

Unfortunately none of the window.open method and the AJAX object XMLHttpRequest worked as I expected.
The first didn't pass any html variables to the php file and also did a refresh to the html page.
The second did not execute the php file possibly because it just opens it as a text reader. It also did a refresh to the html page.

The ideal would be in the
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <FORM method="post" action="http://localhost/phpfile1.php?param1=5&param2=0" >
to add an attribute that would tell the web browser to run this file in the background.
There is the target attribute that tells the browser the target window where the action file will output.

I still cannot find a way to run the action in the background.

Does anyone have any suggestions?
I really need to fix that.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kostas Theof is offline Offline
9 posts
since Jan 2009
Jan 8th, 2009
0

Re: Execute external files via event handlers

If you want to execute an action [i.e. send a HTTP request] without reloading the page, you have two options:
- Remote scripting via hidden IFRAME
- Using the XMLHttpRequest object to make async requests

./sos
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Jan 8th, 2009
0

Re: Execute external files via event handlers

Thank you ~s.o.s~, you solved my problem in a pretty good manner.
I had kind of solved it this way:
by adding on the input tag the event handlers:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. onMouseUp="setTimeout(function(){ winStop()},500);"
  2. onKeyPress="setTimeout(function(){ winStop()},500);"
this way I called the JavaScript function winStop which is defined as follows:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. function winStop() //function that stops the efforts of the web browser to show the results of each PHP file executed
  2. {
  3. if (navigator.appName=='Microsoft Internet Explorer') document.execCommand('Stop');
  4. else window.stop();
  5. } //Tested in both Firefox and Internet Explorer.
but
at first it was not such a nice solution and
at second there was a problem: this stop command whould stop not only the efforts of the web browser to show the results of the execution of the .php file but it also stopped the opening of the main web page that possibly had not finished loading, when the stop function was called.

So, thank you for solving in a much better way my problem.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kostas Theof is offline Offline
9 posts
since Jan 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: javascript gridview
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Slider in Ajax?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC