Tip: You can modify some of the code before running
JavaScript Imitation window Multi-window desktop effect (with analog alert () hint. and confirm ())
Tip: You can modify some of the code before running
solution of the current author has not been studied, but window.open this pop-up window will trigger flashing reminders, but need to solve the user no pop-up window, you can simulate the From submission | | Hyperlinks (a) | | Using browser bubbling, these methods can solve most of the interception situation; But this is not what the author wants, because the hint content is always bad in the pop-up window, the user is very easy to circle, how to have a hint on more than one title bar ... Very a
1. Alert is a pop-up warning box that adds \ n to the text to wrap. 2. Confirm Pop-up confirmation box, will return a Boolean value, through this value can be determined when clicking on the confirmation or cancellation. True indicates click on confirm, false means click Cancel. 3. Prompt popup input box, click Confirm to return the value in the input box,Click Cancel to return null. The following is a detailed example:
Sample code: JSP file NBSP;NB Sp;stringurl = request.getparameter ("url"); stringhasdays = Request.getparameter ("Hasdays"); %> alert ("system hint: your account is about to expire] [remaining" +L t;%= hasdays%>+ "Days"); window.location.href = " System tip: Your account is about to expire!! Remaining response.sendred Irect (URL); %>
Originally hope that the above code implementation: first prompt will expire information, then click
If you directly add \ n to multiple lines in javascript code:Copy codeThe Code is as follows:Alert ("first line \ n Second line "); However, in java code, \ n cannot be used. \ n can only display multiple lines !!!Copy codeThe Code is as follows:String strTemp = "historical answer Report: \ n" + "you answered" + RdData. getCcnt () + "question \ n" + "you have" + RdData. getBcnt () + "No answer \ n" + "Incorrect answer" + RdData. getWcnt () + "question
--The preface--
The alert and confirm standard methods for window objects do not display the same in different browsers, and there is a common point that is not very attractive. Our idea is to use JS and CSS to imitate them, to provide another set of functions, so that in different browsers have the same experience effect.
--Design idea--
To preserve the original alert and confirm methods, instead of dir
Warning (alert)
Did you ever get into a situation like this when you visit a website? "Boom", a small window appears in front of you, with a piece of warning text written, or other information. If you don't click OK, you won't be able to do anything with the page. Yes, this little "boom" window is alert.
The following code is an instance of using alert.
My per
Avascript alert () functionalert--Popup message dialog box (there is an OK button in the dialog box)Alert, meaning of "reminder" in ChineseAlert function syntaxalert (str);alert function Hint Box illustration
Alert function parametersstr--the text to display in the message dialog boxAlert function DescriptionTh
An alert generates the immediate value code in the array, and then the value between min and max. After testing, the Js Code is more practical.
/** Then alert returns the array value * a, indicating the array */function alert1 (a) {var alength =. length; if (alength> 1) {var r = random1 (0, alength); alert (a [r]); a [r] =-1; var temp = Array (alength-1); va
String str = " ";Page. RegisterStartupScript ("prompt", str); // method 1. If the error message is out of date under 2005, consider the following methods: 3rd and 4.Response. Write (str); // method 2, the simplest method/** // /// A dialog box is displayed on the client./// /// Public void Alert (string msg) // method 3...{This. ClientScript. RegisterStartupScript (this. GetType (), "alert", " ");}/** // //
Use JS to get the value of the two-digit input box on the page and compare it to size. The result may be confusing to you, such as code:
The code is as follows
Copy Code
var v1 = $ (' #input1 '). Val ();var v2 = $ (' #input2 '). Val ();Alert (V1 > V2);
If you enter 2 in the INPUT1 input 10,input2. 10 is definitely greater than 2, so the alert box above should pop true,
What are the differences between confirm, alert, and prompt functions in JS? Window. alert: only one parameter. The warning box is displayed;
No return value.
Script
Window. alert ("OK .")
Script
Window. confirm: there is only one parameter. The prompt box is displayed.
Press OK to return true; Press Cancel to return false.
Script
Var bln = window. confir
The two values are added exactly to the specified Number of digits in alert. The following is a good example. For more information, see Number (4.2) + Number (9.2)
The two values are added together with alert, which equals 13.399999999999998. Why?
For example, Number (2.2) + Number (9.7)
Alert output equals 11.899999999999998
But Number (2.3) + Number (9.
Warning (alert)
Did you ever get into a situation like this when you visit a website? "Boom", a small window appears in front of you, with a piece of warning text written, or other information. If you don't click OK, you won't be able to do anything with the page. Yes, this little "boom" window is alert.
The following code is an instance of using alert.
My p
Js files that can be used normally the other day. After some items are added, the prompt box in the alert () dialog box is always garbled with Chinese characters. I have read a lot on the Internet, basically, the answer is to add
Solution:Finally, I found something in a corner of a Forum. I used to specify the character set encoding method when referencing js files in html, the specific method is . It's strange. Why didn't we get garbled in the past
Javascripthtml JS files that can be used normally a few days ago. After some items are added, the prompt box in the alert () dialog box is always garbled in Chinese, and I read a lot on the Internet, basically, the answer is to add
Finally, I found something in a corner of a Forum. I used to specify the character set encoding method when referencing JS files in HTML, the specific method is .
It's strange. Why didn't we get garbled in the past ?....
JavaScript output
JavaScript does not have any functions that print or output.
JAVASCRIPT Displays data
JavaScript can output data in different ways:Use the window.alert() pop-up warning box.Use document.write() methods to write content to an HTML document.Use innerHTML write to HTML element.Use console.log() t
Cross-browser Development Experience Summary (3) be alert to "IE dependency syndrome"
DHTML
DHTML is a good thing. It greatly enhances the front-end interaction implementation, making it extremely simple to get page elements and modify page elements dynamically. But do all browsers know these syntaxes?
Document. all
Document. all is not recognized by all browsers. To write more common code, you 'd better use the id to get it. Use document. getElementB
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.