iOS mobile (H5) alert/confirm hint message removal URL

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.