20.4. Clearing Variable Values (Passwords and Personal Data)
WML variables have a global scope. Once you have set the value of a variable, you can read it in any cards and decks, including cards and decks of another WAP site. If you store a password or some personal data in a variable, you should clear it after use.
Clearing the value of a variable is straightforward. Just assign an empty string to the variable using a way we discussed in the earlier section "Setting Variable Values in WML". Here is an example that makes use of the <setvar/> tag to clear a variable:
<setvar name="var1" value=""/>
20.4.1. The newcontext Attribute
The newcontext attribute of the <card> tag can also be used to clear variable values. The value of the newcontext attribute can either be true or false (default value). If it is specified to true, the WAP browser will reset to the initial state. The navigational history and all WML variables will be cleared as a result. One drawback of using the newcontext attribute to clear variable values is that a user will not be able to go back to a previous card, since the navigational history is removed.
The newContext() function of WMLScript's WMLBrowser standard library does the same thing as the newcontext attribute. The newContext() function does not take any parameters. To call it, just place the line below in a WMLScript function:
WMLBrowser.newContext();
Previous Page | Page 45 of 50 | Next Page | ![]() |
- 1. WML (Wireless Markup Language) Introduction
- 2. WML Deck and Card
- 3. WML Document Structure
- 4. WML Generic Metadata: <meta>
- 5. Comments in WML
- 6. Line Breaking in WML
- 7. Font Size and Style in WML
- 8. WML Preformatted Text: <pre>
- 9. WML Images
- 10. WML Tables
- 11. WML Anchor Links
- 12. Programming Softkeys of Mobile Phones and the <do> Element
- 13. WML Template and Menu
- 14. WML Events and the <onevent> Tag
- 15. Timer and the ontimer Event
- 16. WML Event: onenterbackward
- 17. WML Event: onenterforward
- 18. WML Selection Lists and the onpick Event
- 19. WML Input Fields
- 20. WML Variables
- 21. Submitting Form Data to the Server in WML
- 22. Clearing a Saved Form in WML