I'm trying to load a popup from javascript, which works, however, when I click to close the popup it nothing happens

问题: I've wrote the below code to load a popup when a page loads, however, when I click 'Continue' to close the popup - nothing happens. The button indents but the popup stays p...

问题:

I've wrote the below code to load a popup when a page loads, however, when I click 'Continue' to close the popup - nothing happens. The button indents but the popup stays put. I was wondering if anybody had any ideas?

<p>This is the normal text that would be on the page anyway.</p>

<p>There's an awful lot of this text on a normal page with lots of graphics and stuff as well.</p>


<div id="reminderPopup">
    <div class="popupBackground">
        <div class="popupInner">
            <h2>Remember, if you have opened and resolved a complaint on this call to close the ADR.</h2>
            <p><!--additional text here--></p>
            <button id="close" onclick="closeReminderPopup()">Continue</button>
            <p>&nbsp;</p>
        </div>
    </div>
</div>

<script type="text/javascript"> 
function pageLoadCompleteEvent(){
    document.getElementById("reminderPopup").style.display="block";
};
function closeReminderPopup(){
    document.getElementById("reminderPopup").style.display="none";
};  
</script>


回答1:

Your code works fine. Try running it in the code snippet tool:

	function pageLoadCompleteEvent(){
		document.getElementById("reminderPopup").style.display="block";
	};
	function closeReminderPopup(){
		document.getElementById("reminderPopup").style.display="none";
	};	
<html>
<body>
	<p>This is the normal text that would be on the page anyway.</p>
	
	<p>There's an awful lot of this text on a normal page with lots of graphics and stuff as well.</p>
	

	<div id="reminderPopup">
		<div class="popupBackground">
			<div class="popupInner">
				<h2>Remember, if you have opened and resolved a complaint on this call to close the ADR.</h2>
				<p><!--additional text here--></p>
				<button id="close" onclick="closeReminderPopup()">Continue</button>
				<p>&nbsp;</p>
			</div>
		</div>
	</div>
</body>
</html>

  • 发表于 2019-02-28 14:09
  • 阅读 ( 171 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除