471,316 Members | 1,514 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

WRITE JAVA CODE

hi,

i'm writing java code inside <body> tag of java script file. all the
java code is executing at frame startup. how can i call that java code
only when i click on a button.
I can call jscript function on button click , but i want to call java
code on button click.

advise some solution.

Many Thanx.

Feb 25 '06 #1
4 3745
<script>
function test() {
// enter your java code here
}
</script>

<html>
<head></dead>
<body>
<input type="button" onClick="test();">
</body>

Thid will work.Have fun.:D
</html>

Feb 25 '06 #2
Khan wrote:
i'm writing java code inside <body> tag of java script file.
Two problems there...

1. A JavaScript file should contain JavaScript, not Java. Java and
JavaScript are two entirely different languages.

2. A JavaScript file should contain JavaScript, not HTML, so there should be
no <body> tag.
all the java code is executing at frame startup.
It's actually executing? I'm amazed. Perhaps you mean "JavaScript" when you
say "java", and there is some error correction going on to correct the
markup you've put there.

Oh - http://allmyfaqs.net/faq.pl?Problems_with_using_frames
how can i call that java code only when i click on a button.
Wrap it in a function. Call that function from the onClick hander of the
button.
I can call jscript function on button click , but i want to call java
code on button click.


Now I'm really confused. You can do this with Microsoft's JScript language,
but not JavaScript? Or you really do have some Java around? Or you are
using scripting to play with publically exposed methods of a Java applet?

Providing a URL might make it easier for people to help you. Preferably a
minimal test case.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Feb 25 '06 #3
ghlex, i tried that but nothing hapenning , on bottom of page the
message is "error on page".

Feb 25 '06 #4
Khan wrote on 25 feb 2006 in comp.lang.javascript:
ghlex, i tried that but nothing hapenning , on bottom of page the
message is "error on page".


Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the article
headers. <http://www.safalra.com/special/googlegroupsreply/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 25 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Ravi | last post: by
5 posts views Thread by genc ymeri | last post: by
4 posts views Thread by momobear | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.