IOS Mobile End (H5) alert/confirm hint information removal url (URL) _ios

Source: Internet
Author: User
Tags base64 http request

The recent mobile-end project uses alert and confirm for informational hints, but finds that in iOS systems, a single URL is added to each message.

So how do you get rid of the address hint, and then rewrite the alert and confirm methods by finding and implementing the discovery to resolve the problem.
The code is as follows:

To override the Alert method:

Window.alert = function (name) {
  var iframe = document.createelement ("iframe");
  Iframe.style.display= "None";
  Iframe.setattribute ("src", ' data:text/plain, ');
  Document.documentElement.appendChild (IFRAME);
  Window.frames[0].window.alert (name);
  Iframe.parentNode.removeChild (IFRAME);
 

To override the Confirm method:

window.confirm = function (message) {
   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 result = alertFrame.window.confirm (message);
   Iframe.parentNode.removeChild (IFRAME);
   return result;
 };

Where the Confirm method wants to return the result of the child frame. Otherwise, the default is the effect of cancel.

Derivative knowledge points:

URL of the data type in HTML

For some small data, you can embed it directly in a Web page, rather than from an external file, such as a picture. The advantage of this is that you can reduce the HTTP request one time, the disadvantage is to make the content of the page become larger. The data type URL format has been proposed in 98, now most browsers can support, such as the use of the IE6 kernel of the domestic browser, Chrome and Firefox, but IE8 on the use of problems, the picture shows incomplete.

The URL of the data type has the following several forms:

 data:,< Text data > 
 data:text/plain,< Text data > 
 data:text/html, 
 

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

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.