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.

Recommended Answers

All 4 Replies

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

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

<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.

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:

onMouseUp="setTimeout(function(){ winStop()},500);"
onKeyPress="setTimeout(function(){ winStop()},500);"

this way I called the JavaScript function winStop which is defined as follows:

function winStop() //function that stops the efforts of the web browser to show the results of each PHP file executed
		{ 
		if (navigator.appName=='Microsoft Internet Explorer') document.execCommand('Stop'); 
		else window.stop(); 
		} //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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.