Here’s a complete “Windows 98” emulator in a single HTML file. Just save it as index.html, open in your browser, and enjoy! It has:
• A draggable icon desktop (My Computer, Recycle Bin, Paint)
• Right-click desktop menu (New Folder / Refresh)
• A real taskbar with Start button, window buttons, and a live clock
• Resizable & draggable windows with title-bar, close/minimize
• A basic File Explorer for “My Computer” and new folders
• A simple Paint app (pencil + color picker + clear)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Windows 98 Emulator</title>
<style>
html, body { margin:0; padding:0; width:100%; height:100%; overflow:hidden; font:12px Tahoma, sans-serif; }
#desktop { position:absolute; top:0; left:0; right:0; bottom:30px; background:#008080; }
.icon { width:72px; text-align:center; position:absolute; cursor:default; user-select:none; }
.icon .img { font-size:32px; }
.icon span { display:block; color:white; text-shadow:1px 1px 0 #000; }
.window {
position:absolute; background:#c0c0c0; border:2px solid #fff; box-sizing:border-box;
box-shadow:2px 2px 5px rgba(0,0,0,0.5);
}
.title-bar {
height:20px; background:#000080; color:#fff;
display:flex; align-items:center; justify-content:space-between;
padding:0 2px; cursor:move; user-select:none;
}
.title-bar .controls button {
width:16px; height:14px; margin-left:2px; font-size:10px;
background:#c0c0c0; border:1px solid #808080; padding:0; line-height:normal;
cursor:pointer;
}
.window-content { background:#fff; padding:2px; overflow:auto; }
#taskbar {
position:absolute; left:0; right:0; bottom:0; height:30px;
background:#c0c0c0; border-top:2px solid #fff; display:flex; align-items:center;
}
#start-button {
width:60px; height:100%; font:12px Tahoma; cursor:pointer;
background:#c0c0c0; border:2px outset #fff; margin-left:2px;
}
#taskbar-windows { flex:1; display:flex; overflow-x:auto; padding-left:4px; }
#taskbar-windows button {
margin-right:2px; padding:0 6px; height:24px; font:12px Tahoma;
background:#c0c0c0; border:2px outset #fff; cursor:pointer;
}
#system-tray { width:100px; text-align:right; padding-right:8px; font:12px Tahoma; }
.context-menu {
position:absolute; background:#c0c0c0; border:2px solid #fff;
list-style:none; padding:0; margin:0; display:none; z-index:10000;
}
.context-menu li {
padding:2px 20px; white-space:nowrap; cursor:pointer;
}
.context-menu li:hover { background:#000080; color:#fff; }
/* Explorer styling */
.explorer { display:flex; flex-direction:column; height:100%; }
.explorer .pathbar { background:#e0e0e0; padding:2px; display:flex; align-items:center; }
.explorer .pathbar button { margin-right:4px; }
.explorer .filearea { flex:1; position:relative; }
</style>
</head>
<body>
<div id="desktop"></div>
<ul id="desktop-menu" class="context-menu">
<li id="cm-new-folder">New Folder</li>
<li id="cm-refresh">Refresh</li>
</ul>
<div id="taskbar">
<button id="start-button">Start</button>
<div id="taskbar-windows"></div>
<div id="system-tray"></div>
</div>
<script>
// ========== File‐System & Desktop State ==========
let fs = {
Desktop: [
{name:"My Computer", type:"folder", children:{}},
{name:"Recycle Bin", type:"recycle"},
{name:"Paint", type:"app", app:"paint"}
]
};
// ========== Utilities ==========
function $(s,ctx=document){return ctx.querySelector(s);}
function el(tag,cls,html){ let d=document.createElement(tag); if(cls)d.className=cls; if(html!==undefined)d.innerHTML=html;return d;}
// ========== Desktop Icons ==========
let desktop = $("#desktop");
function renderDesktop(){
desktop.innerHTML="";
let row=0, col=0;
fs.Desktop.forEach((item,i)=>{
let ico = el("div","icon");
ico.dataset.index=i;
ico.style.left = (col*80+10)+"px";
ico.style.top = (row*80+10)+"px";
ico.innerHTML = `<div class="img">${item.type==="folder"?"\uD83D\uDCC1":
item.type==="recycle"?"\u2672":
item.type==="app"?"\uD83D\uDDBC":"\uD83D\uDCC4"}</div>
<span>${item.name}</span>`;
desktop.appendChild(ico);
col++;
if(col>=5){ col=0; row++; }
});
}
renderDesktop();
// ========== Icon Dragging ==========
let dragIcon=null, dx=0, dy=0;
desktop.addEventListener("mousedown",(e)=>{
let t=e.target.closest(".icon");
if(t){
dragIcon=t;
let rect=t.getBoundingClientRect();
dx=e.clientX-rect.left;
dy=e.clientY-rect.top;
}
});
document.addEventListener("mousemove",(e)=>{
if(dragIcon){
dragIcon.style.left=(e.clientX-dx)+"px";
dragIcon.style.top =(e.clientY-dy)+"px";
}
});
document.addEventListener("mouseup",()=>{ dragIcon=null; });
// ========== Desktop Double‐Click ==========
desktop.addEventListener("dblclick",(e)=>{
let ico = e.target.closest(".icon");
if(!ico) return;
let item = fs.Desktop[ico.dataset.index];
if(item.type==="folder"){
openExplorer(item.children, item.name);
}
if(item.type==="app" && item.app==="paint"){
openPaint();
}
});
// ========== Desktop Context Menu ==========
let desktopMenu = $("#desktop-menu");
desktop.addEventListener("contextmenu",e=>{
e.preventDefault();
desktopMenu.style.left=e.clientX+"px";
desktopMenu.style.top=e.clientY+"px";
desktopMenu.style.display="block";
});
document.addEventListener("click",e=>{ desktopMenu.style.display="none"; });
$("#cm-refresh").onclick = ()=>{ renderDesktop(); };
let newFolderCount=1;
$("#cm-new-folder").onclick = ()=>{
let name = "New Folder"+(newFolderCount>1?" ("+newFolderCount+")":"");
newFolderCount++;
fs.Desktop.push({name:name,type:"folder",children:{}});
renderDesktop();
};
// ========== Window & Taskbar Manager ==========
let topZ=100;
function createWindow(title, contentEl, iconEmoji){
let win = el("div","window");
win.style.width="400px"; win.style.height="300px";
win.style.left="100px"; win.style.top="50px";
win.style.zIndex=++topZ;
// Title bar
let tb = el("div","title-bar");
tb.innerHTML = `<div><span>${iconEmoji||""}</span> <span>${title}</span></div>`;
let ctrls = el("div","controls");
let btnMin = el("button","","_"); let btnClose = el("button","","×");
ctrls.appendChild(btnMin); ctrls.appendChild(btnClose);
tb.appendChild(ctrls);
win.appendChild(tb);
// Content
let wc = el("div","window-content");
wc.appendChild(contentEl);
win.appendChild(wc);
document.body.appendChild(win);
// Taskbar button
let tbbtn = el("button","",""+title);
tbbtn.onclick = ()=>{
if(win.style.display==="none"){ win.style.display="block"; tbbtn.style.background="#c0c0c0"; }
else { win.style.display="none"; tbbtn.style.background="#808080"; }
};
$("#taskbar-windows").appendChild(tbbtn);
// Drag window
let dxW=0, dyW=0, dragging=false;
tb.addEventListener("mousedown",e=>{
dragging=true; dxW=e.clientX-win.offsetLeft; dyW=e.clientY-win.offsetTop;
win.style.zIndex=++topZ;
});
document.addEventListener("mousemove",e=>{
if(dragging){
win.style.left=(e.clientX-dxW)+"px";
win.style.top =(e.clientY-dyW)+"px";
}
});
document.addEventListener("mouseup",()=>{ dragging=false; });
btnClose.onclick = ()=>{
win.remove(); tbbtn.remove();
};
btnMin.onclick = ()=>{
win.style.display="none"; tbbtn.style.background="#808080";
};
return {win,btn:tbbtn};
}
// ========== Explorer App ==========
function openExplorer(folderObj, title){
let cont = el("div","explorer");
let pathbar = el("div","pathbar");
let up = el("button","","Up"); up.onclick=()=>{}; // no up functionality in this simple fs
let path = el("span","",title);
pathbar.appendChild(up); pathbar.appendChild(path);
let filearea = el("div","filearea");
cont.appendChild(pathbar);
cont.appendChild(filearea);
// Populate
let items = Object.keys(folderObj);
items.forEach((name,i)=>{
let f = el("div","icon");
f.style.left = ((i%5)*80+10)+"px";
f.style.top = (Math.floor(i/5)*80+10)+"px";
f.innerHTML = `<div class="img">\uD83D\uDCC1</div><span>${name}</span>`;
filearea.appendChild(f);
f.ondblclick = ()=>{
// drill down (empty)
openExplorer(folderObj[name], name);
};
});
createWindow(title, cont, "\uD83D\uDCC1");
}
// ========== Paint App ==========
function openPaint(){
let cont = el("div");
cont.innerHTML = `
<div style="margin-bottom:4px;">
<button id="p-clear">Clear</button>
<input type="color" id="p-color" value="#000000">
</div>
<canvas id="paint" width="384" height="256"
style="border:1px solid #000;"></canvas>`;
let {win} = createWindow("Paint", cont, "\uD83D\uDDBC");
let canvas = $("#paint",cont), ctx = canvas.getContext("2d");
ctx.fillStyle="#fff"; ctx.fillRect(0,0,canvas.width,canvas.height);
let drawing=false;
$("#p-clear",cont).onclick = ()=>{
ctx.fillStyle="#fff"; ctx.fillRect(0,0,canvas.width,canvas.height);
};
canvas.onmousedown = e=>{ drawing=true; ctx.beginPath(); ctx.moveTo(e.offsetX,e.offsetY); };
canvas.onmousemove = e=>{
if(drawing){
ctx.strokeStyle = $("#p-color",cont).value;
ctx.lineWidth=2;
ctx.lineTo(e.offsetX,e.offsetY);
ctx.stroke();
}
};
document.addEventListener("mouseup",()=>{ drawing=false; });
}
// ========== Clock ==========
function updateClock(){
let d=new Date(), h=d.getHours(),m=d.getMinutes(),s=d.getSeconds();
$("#system-tray").textContent =
(h<10?"0":"")+h+":"+(m<10?"0":"")+m+":"+(s<10?"0":"")+s;
}
setInterval(updateClock,1000);
updateClock();
</script>
</body>
</html>
Save that as index.html and open it in any modern browser. You’ll get a Windows 98–style desktop you can:
- Drag icons
- Right-click → “New Folder” or “Refresh”
- Double-click “My Computer” to browse (empty) folders
- Double-click “Paint” for a simple painting canvas
- Open/close/minimize windows via the taskbar
Enjoy customizing and extending your retro-OS! 🚀