Target of the Form. When IFRAME is set to hide, the current page form can be submitted without jump refreshing. The Code is as follows: Prepare a form and an IFRAME on the homepage.
Java code
- <Form action = "submitted action" method = "Post" target = "myiframe">
- .....................
- </Form>
- <IFRAME name = "myiframe" style = "display: none"> </iframe>
<Form action = "submitted action" method = "Post" target = "myiframe"> ..................... </form> <IFRAME name = "myiframe" style = "display: none"> </iframe>
After the action is submitted, the action returns a string of JavaScript statements.
JS Code
- String script = "<SCRIPT> alert ('Hello! '); </SCRIPT> ";
- Response. getoutputstream (). Write (script. getbytes ("UTF-8 "));
String script = "<SCRIPT> alert ('Hello! '); </SCRIPT> "; response. getoutputstream (). Write (script. getbytes (" UTF-8 "));
Alert ('hello') will be executed on the current page. The principle is that the results submitted by form are executed in the IFRAME specified by target,
IFRAME is hidden. In this way, the effect after submission is the same as that after refreshing.
Form target usage to achieve no refreshing of new pages