A few days ago write mobile project with alert and confirm information hint, but found in the iOS system, each prompt message will be added a line URL address, Android did not, after the search, as expected, compatible!! Compatible!!! Compatible!!!
Need to re alert and confirm, no nonsense, look at the code!
Alert rewrite
<script type= "Text/javascript" > var walert = Window.alert; Window.alert = function (message) { try { var iframe = document.createelement ("iframe"); Iframe.style.display = "None"; Iframe.setattribute ("src", ' data:text/plain, '); Document.documentElement.appendChild (IFRAME); var alertframe = window.frames[0]; var iwindow = Alertframe.window; if (Iwindow = = undefined) { Iwindow = Alertframe.contentwindow; } Iwindow.alert (message); Iframe.parentNode.removeChild (iframe); } catch (exc) { return Walert (message); } } </script>
Confirm Rewrite
<script>var wconfirm = window.confirm; window.confirm = function (message) { try { var iframe = document.createelement ("iframe"); Iframe.style.display = "None"; Iframe.setattribute ("src", ' data:text/plain, '); Document.documentElement.appendChild (IFRAME); var alertframe = window.frames[0]; var iwindow = Alertframe.window; if (Iwindow = = undefined) { Iwindow = Alertframe.contentwindow; } var result=iwindow.confirm (message); Iframe.parentNode.removeChild (IFRAME); return result; } catch (exc) { return wconfirm (message); } } var r=confirm ("Press a Button"); if (r==true) { document.write ("You pressed ok!"); } else { document.write ("You pressed cancel!"); }
Then learn the URL of the data type in HTML as follows:
URL of data type in HTML
data:,< Text Data >
data:text/plain,< Text data >
data:text/html,<html code >
data:text/html;base64,<base64 encoded HTML code >
< Span class= "Hljs-typedef" > data:text/ Css,<CSS code;
< Span class= "Hljs-typedef" > DATA:TEXT/CSS;BASE64,<BASE64 encoded CSS code;
< Span class= "Hljs-typedef" > data:text/javascript,<javascript code;
< Span class= "Hljs-typedef" > data: TEXT/JAVASCRIPT;BASE64,<BASE64 encoded javascript code;
< Span class= "Hljs-typedef" > data:image/gif;base64,base64 encoded GIF picture data
< Span class= "Hljs-typedef" > DATA:IMAGE/PNG;BASE64,BASE64 encoded PNG image data
< Span class= "Hljs-typedef" > DATA:IMAGE/JPEG;BASE64,BASE64 encoded JPEG picture data
data:image/x-icon;base64,base64 encoded icon image data
iOS Mobile (H5) alert/confirm hint message removal URL