JS Implementation alert shows the method of line wrapping _javascript tips

Source: Internet
Author: User
Tags first row

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.

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.