-1
我需要一些幫助。我想在html頁面加載時自動顯示模態窗口。我在html <body>
中添加了以下<Div>
,並且還附帶了js函數調用。我的js功能在<header>
之內。Modal Div不從javascript調用
function showModal()
{
document.getElementById("openModal").style.display="block" ;
}
<body onload="init()" onkeydown="return selectNextTabKD(event)" onkeypress="if (!selectNextTabKP(event)) return false; else return doEnterKey(event)">
<script type="text/javascript">
showModal() ;
</script>
<div id="banner">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="50%" nowrap class="bannerleft"></td>
<td width="633px" nowrap><img src="../css/<% BrandDir %>/banner.gif"> </td>
<td width="50%" nowrap class="bannerright"></td>
</tr>
</table>
</div>
<!-- Modal message added -->
<!-- <a href="#openModal">Open Message</a> -->
<div id="openModal" class="modalDialog">
<div><a href="#close" title="Close" class="close">X</a>
<h2>Important to Know</h2>
<p>This is a new message dialog window</p>
</div>
</div>
我試過了,但沒有奏效。我已經進一步查看了代碼,並且似乎該頁面正在根據框架加載,這可能是原因。我將添加父母。[1] .document。檢索該id併發布結果。 – alam