|
Posted by Erwin Moller on 03/06/07 13:19
Nader Emami wrote:
> Simon Stienen wrote:
>> On 2007-03-06 12-43-34, Nader Emami wrote:
>>
>>> Would somebody tell me how I use the onmouseover=alert('string') in a
>>> PHP script without using of JavaScript?
>>>
>>> With regards,
>>> Nader
>>
>> Not at all.
>>
>> You could of course get the function handle of MessageBobA from <whatever
>> windows DLL>, if you load the win32_api PHP extension... But even in this
>> case you'd need a Windows server and you'd get a popup on the server, not
>> the client.
>>
>> PHP itself, however, doesn't know popups. (Heck, it even doesn't know
>> frames or pages!)
>
> I am working on a Linux machine. How can I use the JavaScript in this
> case?
Hi Nader,
As others said, you cannot use alert() and onMouseOver() on the server.
They are both JavaScript.
Javascript lives in the browser, not on the server. (Well, you CAN use
JavaScript as a serverside language, but that is seldom seen.)
So what you need is defining what you want in your HTML and simply let PHP
produce that.
Here is an example:
test.php
----------------------
<?php
// this is PHP, do whatever you want here
?>
<html>
<head>
<title>Javascripttest</title>
<script type="text/javascript">
function annoyVisitor(){
alert('Hi');
}
</script>
</head>
<body>
1+1=<?php echo (1+1); ?>
<br>
<span id="bla" onMouseOver="annoyVisitor();">Come over me</a>
</body>
</html>
----------------------
You see that PHP just produces the JavaScript needed.
Remember that PHP ONLY SENDS the html to the browser.
The receiving browser couldn't care less if the data received is from a
static HTML-page with Javascript in it, or comes from PHP.
If you want to know what the browser sees, just 'view source' in your
browser.
Regards,
Erwin Moller
>
> Nader
Navigation:
[Reply to this message]
|