<button class="btn btn-default" ng-click="openModal()">Open Iframe</button>
<div id="omniScriptModal" class="modal">
<div class="iframe-close" ng-click="closeModal()">Close</div>
<iframe id="omniScriptIFrameModal" frameborder="0" allowfullscreen
src="ExternalLink"></iframe>
</div>
Iframe有标签,点击标签内的某个按钮,我需要模型 omniScriptModal 才能关闭。
$scope.openModal = function(){
document.getElementById('omniScriptModal').style.zIndex = 1040;
var buttonComponent = document.getElementById('omniScriptIFrameModal').contentWindow.document.getElementById('IdentifyCaller_nextBtn');
buttonComponent.onclick = function ($scope) {
document.getElementById('omniScriptModal').style.zIndex = -1;
}
}
上面代码中的问题是,如果按钮加载很晚则不起作用或如果iframe中的按钮位于其他内容中标签