SoFunction
Updated on 2025-04-12

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

Recently, mobile projects use alert and confirm for information prompts, but found that in iOS system, a row of URL addresses will be added to each prompt message.

So how to remove the address prompt? Rewriting the alert and confirm methods after searching and realizing the discovery can solve this problem.
The code is as follows:

Rewrite the alert method:

 = function(name){
  var iframe = ("IFRAME");
  ="none";
  ("src", 'data:text/plain,');
  (iframe);
  [0].(name);
  (iframe);
 };

Rewrite the confirm method:

 = function (message) {
   var iframe = ("IFRAME");
    = "none";
   ("src", 'data:text/plain,');
   (iframe);
   var alertFrame = [0];
   var result = (message);
   (iframe);
   return result;
 };

where confirm method returns the result of the subframe. Otherwise, the default is "cancel".

Derivative knowledge points:

url of data type in html

For some small data, it can be embedded directly in a web page instead of loading from external files, such as images. This advantage is that it can reduce a http request, and the disadvantage is that it makes the page content larger. The data-type url format was proposed in 1998. Now most browsers can support it, such as domestic browsers using the IE6 kernel, chrome and firefox, etc., but there are problems with using it on IE8 and the picture display is incomplete.

Data type urls have the following forms:

 data:,<Text data> 
 data:text/plain,<Text data> 
 data:text/html,<HTMLCode> 
 data:text/html;base64,<base64EncodedHTMLCode> 
 data:text/css,<CSSCode> 
 data:text/css;base64,<base64EncodedCSSCode> 
 data:text/javascript,<JavascriptCode> 
 data:text/javascript;base64,<base64EncodedJavascriptCode> 
 data:image/gif;base64,base64EncodedgifImage data 
 data:image/png;base64,base64EncodedpngImage data 
 data:image/jpeg;base64,base64EncodedjpegImage data 
 data:image/x-icon;base64,base64EncodediconImage data 

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.