enter alert in the console without parentheses to see the original code and only see native code
do you test with the console open? you have just tested it with chrome. If the console is open and the console is in focus, alert
will not immediately block the running thread, but will not issue alert
and block the thread until the focus returns to the page from the console. However, if you modify window.location.href
immediately after executing window.location.href
, and the console gets focus again, alert
will not block the thread immediately, and jvm will execute the next statement to modify window.location.href
, which will result in the cancellation of alert
that has not been issued before (I guess).
the conclusion is that do not test this code with the console open.
here is my test code:
setTimeout(() => $.ajax({
url: '/',
type: 'GET',
success: data => {
console.log('Before rua');
alert('Rua!');
console.log('After rua');
window.location.href += '-sharp';
},
error: (...args) => console.log(...args)
}), 1000);
if you do not switch focus back to the page within 1 second, alert
will not be issued, and window.location.href
will be modified immediately; if you switch focus back to the page within 1 second, alert
will be issued, and window.location.href
will be modified after you drop alert
dismiss.
or more simply and rudely:
setTimeout(() => {
console.log('Before rua');
alert('Rua!');
console.log('After rua');
window.location.href += '-sharp';
}, 1000);
same as above, you can see alert
when you switch back to the page within 1 second. After dismiss, window.location.href
will be modified, otherwise alert
will be cancelled.
comparison with the above code:
setTimeout(() => {
console.log('Before rua');
alert('Rua!');
console.log('After rua');
// window.location.href += '-sharp';
}, 1000);
just send out a alert
without modifying window.location.href
. After entering the above code and running it in the console, wait a second to see the console output "Before rua" and "After rua", and then switch the focus back to the page, you will see a alert
pop-up.
to sum up, I guess alert
can also be asynchronous-when the rendering process detects that the current page does not get focus, such as minimized by the user, if the js embedded in the page tries to issue alert
, the rendering process will not immediately pop up alert
, but will put the request in a queue and wait for the next focus to pop up again.
add that the result of the current chrome test is that alert
is issued when the focus is obtained by the console, and the window.location.href
is modified after alert
(the focus is still on the console). The alert
will be cancelled directly. If you minimize the browser, the browser will automatically pop up and issue alert
.
you can implement an alert, by yourself. After clicking OK, perform a jump operation
alert to stop the current operation. After confirmation, the following statement will be executed
A timing examination system is triggered if the click event is triggered within 5 seconds, and if it is not triggered, the system marks the correct answer at the end of the countdown. How to implement ...
...
A picture grows slowly when it slides up to a certain extent. Why does it bring out a line that has been entangled all night? I can t find the reason. ...
my Q starts from scratch, but I want him to write ti+= < p claqss= "title-count " > has answered 8 questions + Q claqss= "title-count " > answered 1 question correctly; wrote like this: ti+= < p claqss= "title-count " > answered 8 questions + Q...
html and .tool-container if there is no width:100%;, the default is not full, why? I hope I can simply build a html to paste my code into it and help me find the problem. Thank you ...
try the events and methods of jqgrid api, are useless, ask the boss what good methods are available ...
the new project found that testing the drop-down on chrome will refresh the page look at Mobile Taobao s implementation of the drop-down and do not know how to achieve it ...
...
how do I get a user s WeChat account (not a nickname)? ...
ask how to write a native js plug-in that supports the cmd,amd,commonjs specification ...
recently read the front-end https: www.w3cplus.com mobil. this article, feel very troublesome, why not learn Android ...
Why does the problem of redirection occur when using ajax to request other websites $.ajax({ url:"https: www.baidu.com", type: GET , headers:{ Access-Control-Allow-Origin : * ...
the great gods help to make suggestions, as shown in the figure ....
such a shopping cart page, how to write the price after deduction with gold coins at the front end is the final total ...
canvas draws multiple ball collisions on the canvas. How can I add a click event to the ball? as far as I know, adding an event to the canvas actually gets an area on the canvas to fix an event? Is it true that the ball can not be added if it keeps ch...
demand is 1: 15 days after the current time is banned, 2: the date range can only be within 7 days. If the start time is the 2nd, the end time cannot be greater than the 8th, and the rest display mouse display is disabled . have you ever done it, ...
...
was originally intended to use a tabs, with two options to put the editor in the second tabpane however, because of the content set for the content part of the editor, the tab is offset, and the two options show half of each visual observation becaus...
use the window.print () method to print the page. It can preview and print normally on the windows platform. On mac, the preview of the chrome browser is blank, but the preview of the safari browser is normal. Ask for a big answer, what may be the cause....
the player I currently use is jPlayer, which requires that the control bar is in the player (such as Tencent iqiyi, where the mouse is moved in and out to show and hide), which can be displayed normally in browsers such as Chrome, but it is found that th...