Click here to Skip to main content
15,068,988 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
https://codepen.io/Kizzyklicks/pen/oNwjBde

What I have tried:

I have confirmed that all the HTML tags embedded in the JavaScript code are all in quote
And also, I have check the letters to make sure that they are the same
Posted
Updated 28-Aug-21 3:58am
Comments
Asif 7969814 28-Aug-21 9:52am
   
This Code will help you to do the same

https://codepen.io/pedrobenoit91/pen/aJGzYg

<script type="text/javascript" src="https://code.jquery.com/jquery-1.8.2.js"></script>
<style type="text/css">
#overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000;
filter:alpha(opacity=70);
-moz-opacity:0.7;
-khtml-opacity: 0.7;
opacity: 0.7;
z-index: 100;
display: none;
}
.cnt223 a{
text-decoration: none;
}
.popup{
width: 100%;
margin: 0 auto;
display: none;
position: fixed;
z-index: 101;
}
.cnt223{
min-width: 600px;
width: 600px;
min-height: 150px;
margin: 100px auto;
background: #f3f3f3;
position: relative;
z-index: 103;
padding: 15px 35px;
border-radius: 5px;
box-shadow: 0 2px 5px #000;
}
.cnt223 p{
clear: both;
    color: #555555;
    /* text-align: justify; */
    font-size: 20px;
    font-family: sans-serif;
}
.cnt223 p a{
color: #d91900;
font-weight: bold;
}
.cnt223 .x{
float: right;
height: 35px;
left: 22px;
position: relative;
top: -25px;
width: 34px;
}
.cnt223 .x:hover{
cursor: pointer;
}
</style>
<script type='text/javascript'>
$(function(){
var overlay = $('<div id="overlay"></div>');
overlay.show();
overlay.appendTo(document.body);
$('.popup').show();
$('.close').click(function(){
$('.popup').hide();
overlay.appendTo(document.body).remove();
return false;
});


 

$('.x').click(function(){
$('.popup').hide();
overlay.appendTo(document.body).remove();
return false;
});
});
</script>
<div class='popup'>
<div class='cnt223'>
<h1>Important Notice</h1>
<p>
We were affected by the fire next door and will remain closed until further notice.
<br/>
<br/>
<a href='' class='close'>Close</a>
</p>
</div>
</div>

Don't declare it within the body of a different function - these are called "nested functions" when you do that..
Nested functions are only available within the body of the function they are defined in: nothing outside that can access them. And that includes the HTML!
   
There were four errors function found on codepen
1. popupwin_prop should be close at line 11 and
2. popup_text is broken string at line no 17
3. settimeout is call wrong at line no 22
4. settimeout is call wrong at line no 10

Checkout this code:

Js:
function closeWin(popup_new)
			{  
				popup_new.close();

           }
           function popupwin_prop(popup_text)
           {
           	popup_new=window.open(' ', 'newWin',  'width=300, height=100');
           	popup_new.document.write(popup_text);
           setTimeout(closeWin , 5000, popup_new);
           }
           function Adver_popup()
           { 
           popup_text="<HTML>\n<HEAD>\n<TITTLE> online shopping .... Feel the difference</TITTLE>\n<body>\n";
           popup_text = popup_text + "<center> \n <br>"; 
           popup_text = popup_text + "<BODY bgcolor='aquamarine'>"; 
           popup_text = popup_text + "<FONT  COLOR='RED'> <p align='Center'>";
            popup_text = popup_text + "<h2> Market online.... Enjoy</h2> </p> </FONT>";
           popup_text = popup_text + "<center> \n <br>"; 
           
           popup_text = popup_text + "</center> \n </BODY>\n</Html>\n"; 
           setTimeout(popupwin_prop, 5000, popup_text);
           }
           document.bgcolor ="#ccffff";
           document.write(navigator.appName);


Html:

<body onLoad="Adver_popup()">
		<p>
		<center>
		<font face="comic sans, century gothic" size="-3">
		
		Market online<br>
			</center>
			</p> 
</body> 
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900