Javascript alert() function
The Javascript alert() function is used to pop up the dialog window. The content can be set by yourself. Some people may mistakenly think that alert is the same as window.open . In fact, the two of them are completely different applications. It can only be said that they are similar. What comes out is the dialog window, and window.open is to open a new window.
Javascript alert() function syntax example
alert (here the text content to be displayed in the pop-up dialog window);
In addition to traditional Chinese, the text content to be displayed can also be used for symbols, and some changes can also be made through ASCII , but HTML can't render the effect, it will only be converted into string values, which is more obvious! Below we prepare three simple examples for reference.
Javascript alert() function implementation example
alert('test text');
alert('test text first line<br>test text second line');
alert('test text first line\ntest text second line ');
</script>
In the example, the first alert will directly pop up the dialog window of "test text", and the second alert will pop up the dialog content of "test text first line<br>test text second line", you can see the HTML <br > The newline symbol does not produce a newline effect. The third alert can successfully wrap by using \n's newline.
Post a Comment
0 Comments