No, javascript cannot be used to switch between a fullscreen and normal mode in Safari on iOS.
The following meta tag must be included, and the page must be launched from a bookmark on the home screen, for it to operate in fullscreen mode:
<meta name="apple-mobile-web-app-capable" content="yes">
However, you can detect if the page is running in fullscreen mode or not with javascript using the read-only property:
window.navigator.standalone