0
親ページがポストバックをしたときにIframeのウェブページがリロードされないようにするにはどうすればよいですか? 以下は単純な.aspxページです。ポストバックを行うButton1をクリックすると、ソースとしてblank.aspxを持つiframeがリロードされます。これを防ぐ方法を教えてください。コードは以下のとおりです。iframeのウェブページを停止してポストバックにリロードする
<div>
This is an empty page with a button to open a modal window in an iframe
<asp:Button ID="Button1" runat="server" Text="Postback" OnClick="Button1_Click" />
<asp:Label ID="lblPostback" runat="server" Text="Initial Load"></asp:Label>
<!-- Trigger/Open The Modal -->
<button id="myBtn" type="button">Open Modal</button>
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
<p>Some text in the Modal..</p>
<iframe src="Site/Public/blank.aspx"></iframe>
</div>
</div>
<script>
// Get the modal
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
//When the user clicks anywhere outside of the modal, close it
window.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
</div>
ありがとうございました。 – enski