Click to See Complete Forum and Search --> : back button
kompressor2278
10-13-2004, 03:17 PM
Hi,
Id like to have it be the last function of a submit button in my applet.
the user clicks on a url to get to the applet, clicks a few buttons, when they're
done they will click the submit button, which will submit their data, and then
bring them back to the previous page.
basically saving them a click.
How would I go about this?
ractoc
10-17-2004, 05:29 AM
If I remember correctly, it should be possible to acces the JavaScript inside the HTML page from within you applet. By doinbg this, you could just call a JavaScript method which will then call document.history.go(-1); which will make the browser go back to the previous page. It's been a long time since I've read about this feature however, so I'm not sure if it's possible and how.
kompressor2278
10-18-2004, 07:01 AM
where did you read about it?
Can anyone else prove / disprove this feature?
**EDIT**
here is what I have tried so far:
if(e.getActionCommand().equals(" SEND ")){
try{
url = new URL(myHost);
con = url.openConnection();
con.setAllowUserInteraction(true);
n=con.getInputStream();
d = new DataInputStream(n);
// back to previous page feature?
burl = new URL("javascript:history.back()");
bcon = burl.openConnection();
bcon.setAllowUserInteraction(true);
bn=bcon.getInputStream();
bd = new DataInputStream(bn);
}catch(Exception x){
inputOutputField.setText("err: bad data");
}
the top part will work, but the back button does not. Any ideas?
kompressor2278
10-18-2004, 08:18 AM
putting that javascript code in my applet gives me an exception:
java.net.UnknownServiceException: protocol doesn't support input
ractoc
10-18-2004, 08:30 AM
Here's a link that tells you how to activate your applet for Javascript acces:
http://forum.java.sun.com/thread.jsp?forum=421&thread=333244
kompressor2278
10-18-2004, 08:36 AM
this guy has some info as well
http://www.xaff.org/JAVA/SPECIAL/mixing.html
but his links are dead to the netscape devel page.
**EDIT**
found the sdk for LiveConnect
http://wp.netscape.com/comprod/development_partners/plugin_api/
http://wp.netscape.com/eng/mozilla/3.0/handbook/plugins/index.html
ractoc
10-18-2004, 08:46 AM
Cool, now you should be on your way
kompressor2278
10-18-2004, 10:13 AM
okay. Ive got it going. and I am able to access javascript in my applet. I have an issue...naturally.
Lets say that the url 'myHost' does not go to a website, but merely sets a flag.
Here is mycode:
html:
<APPLET CODE=test.class WIDTH=600 HEIGHT=750>
</APPLET>
<SCRIPT>
function backme() {
history.back();
}
</SCRIPT>
Applet:
if(e.getActionCommand().equals(" SEND ")){
try{
// set flag
url = new URL(myHost);
con = url.openConnection();
con.setAllowUserInteraction(true);
n = con.getInputStream();
d = new DataInputStream(n);
}catch(Exception x){
inputOutputField.setText("err: bad data");
}
// go back to prevouis page.
JSObject win = JSObject.getWindow(this);
String args[] = {""};
win.call("backme", args);
}
Now when the send button is hit it will only go back to the previous page.
Maybe a sleep() call will help? Im not sure why it does not try to send data to myHost.
Any help would be appreciated.
Im close, I can taste it.
ractoc
10-18-2004, 10:24 AM
did you try the url.connect() method?
and are you sending data through that inputstream?
kompressor2278
10-18-2004, 10:43 AM
I did not try the connect() method and I dont need to send data just connecting to the url is enough.
Oddly enough. a reboot fixed my problem. It now does both. Thank you so much for your help.
devx.com
Copyright Internet.com Inc. All Rights Reserved