Compare commits

...

1 Commits

Author SHA1 Message Date
Claude
107272c9fa Add interactive web page with separate JavaScript file
- Create index.html with interactive buttons and styling
- Create script.js with JavaScript functions for user interactions
- Features include message display, color changing, and date/time display

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-10 02:49:39 +00:00
2 changed files with 102 additions and 0 deletions

64
index.html Normal file
View File

@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sample Web Page</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f4f4f4;
}
.container {
max-width: 800px;
margin: 0 auto;
background-color: white;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
h1 {
color: #333;
text-align: center;
}
.button {
background-color: #007bff;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
margin: 10px 5px;
}
.button:hover {
background-color: #0056b3;
}
#output {
margin-top: 20px;
padding: 15px;
background-color: #f8f9fa;
border-left: 4px solid #007bff;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to My Web Page</h1>
<p>This is a sample web page with JavaScript functionality.</p>
<button class="button" onclick="showMessage()">Show Message</button>
<button class="button" onclick="changeColor()">Change Color</button>
<button class="button" onclick="showDateTime()">Show Date/Time</button>
<div id="output">
<p>Click a button to see JavaScript in action!</p>
</div>
</div>
<script src="script.js"></script>
</body>
</html>

38
script.js Normal file
View File

@@ -0,0 +1,38 @@
// Sample JavaScript functions for the web page
function showMessage() {
const output = document.getElementById('output');
output.innerHTML = '<p><strong>Hello from JavaScript!</strong> This message was generated by the external script file.</p>';
}
function changeColor() {
const output = document.getElementById('output');
const colors = ['#e3f2fd', '#f3e5f5', '#e8f5e8', '#fff3e0', '#fce4ec'];
const randomColor = colors[Math.floor(Math.random() * colors.length)];
output.style.backgroundColor = randomColor;
output.innerHTML = '<p>Background color changed! The new color is: <strong>' + randomColor + '</strong></p>';
}
function showDateTime() {
const output = document.getElementById('output');
const now = new Date();
const dateTimeString = now.toLocaleString();
output.innerHTML = '<p>Current date and time: <strong>' + dateTimeString + '</strong></p>';
}
// Add event listener for when the page loads
document.addEventListener('DOMContentLoaded', function() {
console.log('JavaScript file loaded successfully!');
// You can add any initialization code here
const container = document.querySelector('.container');
if (container) {
container.addEventListener('click', function(event) {
if (event.target.classList.contains('button')) {
console.log('Button clicked:', event.target.textContent);
}
});
}
});