Jump to content

Need help with Javascript


GeorgeFowler

Recommended Posts


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
#advert {
display:none;
border: solid 1px black;
position: fixed;
left: 50%;
top: 50%;
background-color: white;
z-index: 100;

height: 400px;
margin-top: -200px;

width: 600px;
;

}
</style>
<script>
window.onload = function() {
var ad = document.getElementById('advert');

setTimeout(function() {
ad.style.display = 'block';
}, 3000);

document.getElementById('close').onclick = function() {
ad.style.display = 'none';
return false;
}
}
</script>
</head>

<body>
<h3>Wait ...</h3>
<div id="advert">Hello this is an Advert!<a id="close" href="#">Close</a></div>
</body>
</html>

 

Edited by Frank_b
Link to comment
Share on other sites

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
#advert {
	display:none;
	border: solid 1px black;
    position: fixed;
    left: 50%;
    top: 50%;
    background-color: white;
    z-index: 100;

    height: 400px;
    margin-top: -200px;

    width: 600px;
    ;

}
</style>
<script>
window.onload = function() {
	var ad = document.getElementById('advert');
	
	setTimeout(function() {
		ad.style.display = 'block';
	}, 3000);
	
	document.getElementById('close').onclick = function() {
		ad.style.display = 'none';
                return false;
	}
}
</script>
</head>

<body>
<h3>Wait ...</h3>
<div id="advert">Hello this is an Advert!<a id="close" href="#">Close</a></div>
</body>
</html>

Kind of like that but the ad should show onto the page first befoe anything else for a number of seconds before it disappears and the content of the pageis seen. I'm a php coder and no nothing of javascript besides how to read it otherwise I would do it myself. I appreciate the script snip and would love it if you could fix it the way I want it to work.

Link to comment
Share on other sites

Like this?

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
#page {
	display:none;
}

#advert {
	border: solid 1px black;
    position: fixed;
    left: 50%;
    top: 50%;
    background-color: white;
    z-index: 100;

    height: 400px;
    margin-top: -200px;

    width: 600px;
    ;

}
</style>
<script>
window.onload = function() {
	setTimeout(function() {
		document.getElementById('advert').style.display = 'none';
		document.getElementById('page').style.display = 'block';
	}, 3000);
}
</script>
</head>

<body>
<div id="page">
<h3>Hello</h3>
<p>Welcome on my website</p>
</div>
<div id="advert">Hello this is an Advert!</div>
</body>
</html>

Link to comment
Share on other sites

 

Like this?

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
#page {
	display:none;
}

#advert {
	border: solid 1px black;
    position: fixed;
    left: 50%;
    top: 50%;
    background-color: white;
    z-index: 100;

    height: 400px;
    margin-top: -200px;

    width: 600px;
    ;

}
</style>
<script>
window.onload = function() {
	setTimeout(function() {
		document.getElementById('advert').style.display = 'none';
		document.getElementById('page').style.display = 'block';
	}, 3000);
}
</script>
</head>

<body>
<div id="page">
<h3>Hello</h3>
<p>Welcome on my website</p>
</div>
<div id="advert">Hello this is an Advert!</div>
</body>
</html>

Yeah I can work off from that. That works great! Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.