-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove alert() from live samples #7566
Comments
This comment was marked as outdated.
This comment was marked as outdated.
hey can you help me understand the problem i would like to contribute to this |
On two of the remaining pages, there are live example using Such example are bad practice (we should not use The goal is to replace them using a log element that we use to display the alert text instead. The numerous merged PRs show many examples of such conversion. |
thanks for the help @teoli2003 so basically i have to replace alert() with console.log right? and for clear alert() i should do clear message() sorry if this seems silly to you it's my first time and i want it to be right. |
No, it is more complex than that. You need to add an element, like For clearing the message, you simply set a new value with Of course, positioning the message box may be tricky, and it is likely you'll need to expand the size in |
I took a look at this one MDN/Writing_guidelines/Page_structures/Live_samples It's a bit more complex than the original, but still a simple interaction that keeps most elements in the example as is.
|
Yeah, something like that is what we are looking for. |
The https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Page_structures/Live_samples#displaying_a_log_that_appends_items has two examples of how you can create a log to use instead of an alert - one that displays a single "current value" and the other than appends results. This can replace an alert of |
This comment was marked as duplicate.
This comment was marked as duplicate.
The first six files in the list belong to the same tutorial, so they should have the same solution. The |
I'm not very sure. They were brought into live examples by @bsmth, so perhaps he has some ideas here? I think using a |
That was me in #32258 which fixed |
window.alert()
doesn't work cross-origin in Chrome any more, meaning that any of our live samples that rely onalert()
are now broken.See also #7553.
This is (I think) all the live samples in Web/API that use
alert()
in a live sample (list now maintained by @Josh-Cena):Web/API/CanvasRenderingContext2D/addHitRegion(I might have missed some).
In addition, the following ones use
prompt()
and are also broken:We should replace all of these with some alternative. A common alternative is to write the output into an element in the example's document.
The text was updated successfully, but these errors were encountered: