The example in this article describes the method of displaying line wrapping in JS implementation alert. Share to everyone for your reference, specific as follows:
Let's start with a more complicated approach, but this approach can be used to identify any type of browser:
Browser type decision
function Getos ()
{
if (navigator.userAgent.indexOf ("MSIE") >0) {return
"IE"; Internetexplor
}
else if (Isfirefox=navigator.useragent.indexof ("Firefox") >0) {return
"FF"; Firefox
}
else if (Issafari=navigator.useragent.indexof ("Safari") >0) {return
"SF";//safari
}
Else if (Iscamino=navigator.useragent.indexof ("Camino") >0) {return
"C";//camino
}
else if ( Ismozilla=navigator.useragent.indexof ("gecko/") >0) {return
"G";//gecko
}
else if (ismozilla= Navigator.userAgent.indexOf ("Opera") >=0) {return
"O";//opera
}else{return
' other ';
}
function Alert_br () {
var os=getos ();
if (os== ' FF ' | | | | | os== ' SF ') {//firefox, Google Browser with this
alert (' first row \ second row ');
} else{ //ie Series with this
alert (' first line \ r \ n second line);
}
}
ALERT_BR ();
The second is relatively simple, but only a simple distinction between IE and other browsers:
function Alert_br () {
if (!document.all)//ff/{Google Browser with this
alert (' first row \ second row ');
} else{ //ie Series with this
alert (' first line \ r \ n second line);
}
}
ALERT_BR ();
I hope this article will help you with JavaScript programming.