DIV形式的alert提示效果--JS源码[原]

这篇博客展示了如何使用JavaScript创建一个DIV形式的alert提示效果。通过点击按钮,调用DIVAlert函数,显示一个可定制宽度、高度、边框颜色和标题颜色的提示窗口。窗口背景透明,并包含关闭功能。
摘要由CSDN通过智能技术生成
调用方法:
< input type = " button "  value = " 点击我就看到效果了哦`` "  onclick = " DIVAlert('测试!!!'); "   />

JS源码:
< script type = " text/javascript "  language = " javascript " >
      
function  DIVAlert(str) {
      
var msgw,msgh,bordercolor;
      msgw
=400;//提示窗口的宽度
      msgh=100;//提示窗口的高度
      titleheight=25 //提示窗口标题高度
      bordercolor="#336699";//提示窗口的边框颜色
      titlecolor="#99CCFF";//提示窗口的标题颜色
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
以下是一个简单的HTML和JavaScript实现的登录注册界面示例: ```html <!DOCTYPE html> <html> <head> <title>Login/Register Form</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> body { font-family: Arial, sans-serif; background-color: #f2f2f2; } form { background-color: #fff; padding: 20px; max-width: 500px; margin: 0 auto; box-shadow: 0 0 10px rgba(0,0,0,0.3); } h2 { text-align: center; margin-bottom: 20px; } input[type=text], input[type=password] { width: 100%; padding: 12px 20px; margin: 8px 0; display: inline-block; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } button { background-color: #4CAF50; color: white; padding: 14px 20px; margin: 8px 0; border: none; border-radius: 4px; cursor: pointer; width: 100%; } button:hover { background-color: #45a049; } .cancelbtn { background-color: #f44336; } .imgcontainer { text-align: center; margin: 24px 0 12px 0; position: relative; } img.avatar { width: 40%; border-radius: 50%; } .container { padding: 16px; } span.psw { float: right; padding-top: 16px; } @media screen and (max-width: 300px) { span.psw { display: block; float: none; } .cancelbtn { width: 100%; } } </style> </head> <body> <h2>Login/Register Form</h2> <form> <div class="imgcontainer"> <img src="avatar.png" alt="Avatar" class="avatar"> </div> <div class="container"> <label for="username"><b>Username</b></label> <input type="text" placeholder="Enter Username" name="username" required> <label for="password"><b>Password</b></label> <input type="password" placeholder="Enter Password" name="password" required> <button type="submit" id="login-btn">Login</button> <button type="submit" id="register-btn">Register</button> </div> <div class="container" style="background-color:#f1f1f1"> <button type="button" class="cancelbtn">Cancel</button> <span class="psw">Forgot <a href="#">password?</a></span> </div> </form> <script> // Login button event listener document.getElementById("login-btn").addEventListener("click", function() { event.preventDefault(); // Prevent form submission var username = document.getElementsByName("username")[0].value; var password = document.getElementsByName("password")[0].value; // Perform login validation here alert("Login successful!"); }); // Register button event listener document.getElementById("register-btn").addEventListener("click", function() { event.preventDefault(); // Prevent form submission var username = document.getElementsByName("username")[0].value; var password = document.getElementsByName("password")[0].value; // Perform registration validation here alert("Registration successful!"); }); </script> </body> </html> ``` 请注意,这只是一个演示示例,需要根据实际需求进行修改和完善。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值