问题描述
有一个跨窗口iframe,其中包含从另一台服务器到index.PHP的链接,而另一台服务器又具有Yandex maps api脚本(请参见下文)。如何确保此脚本链已完全加载?我正在尝试以下方式:
<script>
function loaded() {
window.parent.postMessage('loaded','*');
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript"></script>
<script src="https://api-maps.yandex.ru/2.1/?apikey=bla-bla-bla&lang=ru_RU" type="text/javascript" onload="loaded()"></script>
解决方法
订阅ymaps.ready()
。 https://tech.yandex.com/maps/jsapi/doc/2.1/ref/reference/ready-docpage/
ymaps.ready(() => notify())