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.