OlegTimkiv Posted October 27, 2021 Share Posted October 27, 2021 Добрый день! Подскажите пожалуйста, во фрейме отображаю сайт где осуществляться чтение из буфера. Something went wrong DOMException: The Clipboard API has been blocked because of a permissions policy applied to the current document. See - https://goo.gl/EuHzyv for more details. - Как можно настроить политику разрешений у фрейма? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 27, 2021 Share Posted October 27, 2021 Добрый вечер, А что Вы отображаете? Quote Link to comment Share on other sites More sharing options...
OlegTimkiv Posted October 28, 2021 Author Share Posted October 28, 2021 17 hours ago, Sherzod said: Добрый вечер, А что Вы отображаете? Компонент richEdit от devexpress, там нужна вставка из буфер, пробую через navigator.clipboard.readtext Quote Link to comment Share on other sites More sharing options...
OlegTimkiv Posted October 30, 2021 Author Share Posted October 30, 2021 On 10/27/2021 at 9:23 PM, Sherzod said: Добрый вечер, А что Вы отображаете? Добрый вечер! проект на asp mvc, копируем с буфера : <div> <h3 class="clipboard-results"></h3> <button class="read-btn">Paste from clipboard</button> </div> <script> const readBtn = document.querySelector('.read-btn'); const resultsEl = document.querySelector('.clipboard-results'); const inputEl = document.querySelector('.to-copy'); readBtn.addEventListener('click', () => { navigator.clipboard.readText() .then(text => { resultsEl.innerText = text; }) .catch(err => { console.log('Something went wrong', err); }) }); </script> Просто html: <iframe src="https://localhost:44321/Home/Index" ></iframe> Ошибка: Something went wrong DOMException: The Clipboard API has been blocked because of a permissions policy applied to the current document. See - https://goo.gl/EuHzyv for more details Если добавить атрибут allow: <iframe allow="clipboard-read; clipboard-write" src="https://localhost:44321/Home/Index" ></iframe> То вставка работает корректно. Можно в TUniURLFrame настроить атрибут allow? Или дело в чем-то другом. Clipboardt.7z Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 30, 2021 Share Posted October 30, 2021 Добрый вечер, Простите за поздний ответ. Но, я так и не понял Ваш случай... Связано ли это вообще с UniGUI. Кажется Вы используете VCL приложение, не так ли? Quote Link to comment Share on other sites More sharing options...
OlegTimkiv Posted October 30, 2021 Author Share Posted October 30, 2021 12 minutes ago, Sherzod said: Добрый вечер, Простите за поздний ответ. Но, я так и не понял Ваш случай... Связано ли это вообще с UniGUI. Кажется Вы используете VCL приложение, не так ли? Если в проекте UniGUI, в URLFrame подгрузить TestClipboard.html c приложенного архива, все работает корректно. Стоит открыть проект на asp с дебага, появляться ошибка. AttributeAllow.html без атрибута allow такая же ошибка, если использовать iframe. Вот думаю что проблема такая же у TUniURLFrame. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 31, 2021 Share Posted October 31, 2021 11 hours ago, OlegTimkiv said: Если в проекте UniGUI, в URLFrame подгрузить TestClipboard.html c приложенного архива, все работает корректно. Стоит открыть проект на asp с дебага, появляться ошибка. Я не смог запустить полностью Ваш тестовый случай... Мне кажется Вам нужно смотреть в сторону CORS Quote Link to comment Share on other sites More sharing options...
OlegTimkiv Posted October 31, 2021 Author Share Posted October 31, 2021 3 hours ago, Sherzod said: Я не смог запустить полностью Ваш тестовый случай... Мне кажется Вам нужно смотреть в сторону CORS Сначала думал что cors. UniURLFrame добавляю в html "<iframe allow="clipboard-read; clipboard-write" src="https://localhost:44321/Home/Index" ></iframe> " -работает корректно. В проекте asp пробовал отключить cors, но все же ошибка сохраняться. Или что-то я не понимаю. Quote Link to comment Share on other sites More sharing options...
OlegTimkiv Posted October 31, 2021 Author Share Posted October 31, 2021 4 hours ago, Sherzod said: Я не смог запустить полностью Ваш тестовый случай... Мне кажется Вам нужно смотреть в сторону CORS Подскажите пожалуйста, как можно в UniURLFrame добавить атрибут allow? Quote Link to comment Share on other sites More sharing options...
OlegTimkiv Posted October 31, 2021 Author Share Posted October 31, 2021 5 hours ago, Sherzod said: Я не смог запустить полностью Ваш тестовый случай... Мне кажется Вам нужно смотреть в сторону CORS function afterCreate(sender) { var me = sender; document.getElementById(me.id).setAttribute("allow", "clipboard-read; clipboard-write"); } По идеи так должно было сработать. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 31, 2021 Share Posted October 31, 2021 17 minutes ago, OlegTimkiv said: По идеи так должно было сработать. Возможно, что у Вас не будет доступа к контенту страницы с другого домена загруженной в iframe. Quote Link to comment Share on other sites More sharing options...
OlegTimkiv Posted October 31, 2021 Author Share Posted October 31, 2021 Just now, Sherzod said: Возможно, что у Вас не будет доступа к контенту страницы с другого домена загруженной в iframe. Подскажите а другие способы есть? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 31, 2021 Share Posted October 31, 2021 4 hours ago, OlegTimkiv said: В проекте asp Вы должны добавить в список доверенных доменов (Ваш UniGUI web сервер) https://ru.wikipedia.org/wiki/Cross-origin_resource_sharing Quote Link to comment Share on other sites More sharing options...
OlegTimkiv Posted October 31, 2021 Author Share Posted October 31, 2021 2 hours ago, Sherzod said: Вы должно добавить в список доверенных доменов (Ваш UniGUI web сервер) https://ru.wikipedia.org/wiki/Cross-origin_resource_sharing Добавлял, ошибка тая же. Почему тогда добавляю атрибуты все работает. bandicam 2021-10-31 18-04-55-230.mp4 Quote Link to comment Share on other sites More sharing options...
OlegTimkiv Posted November 8, 2021 Author Share Posted November 8, 2021 On 10/31/2021 at 3:41 PM, Sherzod said: Вы должны добавить в список доверенных доменов (Ваш UniGUI web сервер) https://ru.wikipedia.org/wiki/Cross-origin_resource_sharing Добрый день! Подскажите пожалуйста во фрейм никак не получиться добавить атрибуты allow="clipboard-read; clipboard-write"? Что только не пробовал, все без успешно. Если дело было в корс, то сервис был бы не доступен. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 8, 2021 Share Posted November 8, 2021 Здравствуйте, Какие ошибки получаете, в консоле браузера? Quote Link to comment Share on other sites More sharing options...
OlegTimkiv Posted November 8, 2021 Author Share Posted November 8, 2021 4 minutes ago, Sherzod said: Здравствуйте, Какие ошибки получаете, в консоле браузера? The Clipboard API has been blocked because of a permissions policy applied to the current document. See https://goo.gl/EuHzyv for more details Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 8, 2021 Share Posted November 8, 2021 Попробуйте такой подход тогда: procedure TMainForm.UniURLFrame1FrameLoaded(Sender: TObject); begin // UniURLFrame1.JSInterface.JSCall('iframe.setAttribute', ['allow', 'clipboard write; clipboard read']); end; Quote Link to comment Share on other sites More sharing options...
OlegTimkiv Posted November 8, 2021 Author Share Posted November 8, 2021 18 minutes ago, Sherzod said: Попробуйте такой подход тогда: procedure TMainForm.UniURLFrame1FrameLoaded(Sender: TObject); begin // UniURLFrame1.JSInterface.JSCall('iframe.setAttribute', ['allow', 'clipboard write; clipboard read']); end; Огромное спасибо Вам! Заработало! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.