Почему у меня не получается выделять текст alert?
Если значение alert записано в одну строчку(пример 1), то текст можно выделить мышью. Почему если значение alert записано более, чем в одну строчку(пример 2), то не получается выделить текст мышью?
Пример 1:
let guestList = "Guests: John, Pete, Mary";
alert(guestList);
Пример 2:
let guestList = "Guests:\n * John\n * Pete\n * Mary";
alert(guestList);
Ответы (1 шт):
Вот что нашел на просторах SO
I've found that, in Chrome at least, the alert box text is in fact selectable -- when the text does not contain any line-breaks (ie. "\n").
I don't know why this is the case, but I've had to use this trick before for quick selection prompts. (you could also use prompt("please press ctrl+c to copy the text below", "text to copy"), but that usually looks worse)
Указанная проблема касается только Chrome. Проверял на FireFox там все нормально.
А вот тут на комюнити тоже о том же говорят