In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to stop execution with javascript". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The method to stop the execution of javascript: 1, open the corresponding js code file; 2, terminate the function operation through the return method, such as "function testA () {alert ('a'); return;alert ('b');}".
This article operating environment: windows7 system, javascript1.8.5 version, DELL G3 computer
How does javascript stop execution?
Javascript terminates the function to perform the operation
1. If you terminate a function, you can use return. The example is as follows:
Function testA () {alert ('a'); alert ('b'); alert ('c');}
TestA (); the execution of the program will pop up in turn: 'axiomagery', baccalaureate, etc., etc.
Function testA () {
Alert ('a')
Return
Alert ('b')
Alert ('c')
}
TestA (); the program execution will be terminated by popping up'a'.
2. Call another function in the function. When the called function terminates, the function you want to call also terminates. The example is as follows:
Function testC () {alert ('c'); return; alert ('cc');} function testD () {testC (); alert (' d');}
TestD (); We see that testC is called in testD, and testD is terminated through return in testC. Instead, return only terminates testC, and the program execution pops up "centering, writing and writing" in turn.
Function testC () {
Alert ('c')
Return false
Alert ('cc')
}
Function testD () {
If (! testC ()) return
Alert ('d')
}
TestD (); two functions have been modified, and the return value of testC is judged in the false,testD returned in testC, so that the testD can be terminated when the testC is terminated, and the program execution will be terminated by popping up'c'.
This is the end of "how to stop execution with javascript". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.