back button


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 10 of 10

Thread: back button

  1. #1
    Join Date
    Oct 2004
    Posts
    6

    back button

    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?

  2. #2
    Join Date
    Oct 2004
    Posts
    311
    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.

  3. #3
    Join Date
    Oct 2004
    Posts
    6
    where did you read about it?

    Can anyone else prove / disprove this feature?

    **EDIT**

    here is what I have tried so far:
    Code:
    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?

  4. #4
    Join Date
    Oct 2004
    Posts
    6
    putting that javascript code in my applet gives me an exception:

    Code:
    java.net.UnknownServiceException: protocol doesn't support input

  5. #5
    Join Date
    Oct 2004
    Posts
    311
    Here's a link that tells you how to activate your applet for Javascript acces:


    http://forum.java.sun.com/thread.jsp...&thread=333244

  6. #6
    Join Date
    Oct 2004
    Posts
    6
    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/devel...rs/plugin_api/

    http://wp.netscape.com/eng/mozilla/3...ins/index.html

  7. #7
    Join Date
    Oct 2004
    Posts
    311
    Cool, now you should be on your way

  8. #8
    Join Date
    Oct 2004
    Posts
    6
    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:
    Code:
    <APPLET CODE=test.class WIDTH=600 HEIGHT=750>
    </APPLET>
    
    <SCRIPT>
    function backme() {
    	history.back();
    }
    </SCRIPT>
    Applet:
    Code:
    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.

  9. #9
    Join Date
    Oct 2004
    Posts
    311
    did you try the url.connect() method?
    and are you sending data through that inputstream?

  10. #10
    Join Date
    Oct 2004
    Posts
    6
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center