Skip to content

ThirteeNov

My personal blog about coding and internet

Menu
  • About me
  • About Zofia Kreasi
  • Cart
  • Checkout
  • Making an airplane game from scratch in Unity
  • My account
  • Privacy Policy
  • Privacy Policy – zkLeaderboard
  • Sample Page
  • Shop
  • Tutorials on Learning JavaScript
  • ZKAccounts – Privacy Policy
Menu

Creating custom JavaScript alert

Posted on September 4, 2017August 4, 2020 by Habibie

Simple JavaScript alert that you usually call like this alert("Hai!"); may be little bit boring. So here come an idea to create custom alert that you can style it as you wish.

Here is the code and give it a try:

<!DOCTYPE html>
<html>
	<head>
		<title>Custom JavaScript Alert</title>
		<style>
			#ca{
				position: fixed;
				left: 60px;
				right: 60px;
				bottom: 60px;
				padding: 20px;
				background-color: red;
				color: white;
				border-radius: 20px;
				text-align: center;
				display: none;
			}
		</style>
	</head>
	<body>
		<div id="ca">Hi There!</div>
		<button onclick="simpleAlert()">Alert</button>
		<button onclick="customAlert()">Custom Alert</button>
		<script>
			function simpleAlert(){
				alert("Hi there!");
			}
			function customAlert(){
				document.getElementById("ca").style.display = "block";
				setTimeout(function(){
					document.getElementById("ca").style.display = "none";
				}, 1000);
			}
		</script>
	</body>
</html>
Post Views: 379
ciihuy2020

Welcome!

  • My YouTube Channel
  • My GitHub Page
  • About me

Categories

  • 3DVista
  • Android
  • Apache
  • C#
  • Cordova
  • Electron & Node JS
  • HTML5, CSS & JavaScript
  • iOS
  • Let's Make Unity Games
  • Misc
  • Photoshop
  • PHP
  • Python
  • Uncategorized
  • Unity
  • WordPress

Recent Posts

  • Hover Reveal script for Unity to show and hide object on mouse hover
  • How to Prevent UI Clicks in Unity from “Bleeding Through” to 3D Objects Behind Them
  • Make objects like wires and cables easily in Unity using Ciihuy Curved Mesh
  • [SOLVED] Can’t Add Custom Domain to Blogger After Losing CNAME Verification
  • iOS App Icon Generator by CiihuyCom
© 2026 ThirteeNov | Powered by Superbs Personal Blog theme