html5+css3+javascript 自定义提示窗口
效果图:

源码:
1.demo.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>自定义提示窗口</title>
<script type="text/javascript" src="js/myAlert.js"></script>
<script type="text/javascript">
function bodyOnload() {
var myInput = document.getElementById("myInput");
myInput.style.border = "none";
myInput.style.backgroundColor = "rgba(223, 230, 223, 0.3)";
myInput.value = "请输入你的名字:";
myInput.onfocus = function () {
myInput.style.outline = "none";
myInput.value = "";
};
var image_div = document.createElement("div");
image_div.style.width = myInput.offsetHeight ;
image_div.style.height = myInput.offsetHeight;
image_div.style.float = "right";
image_div.style.cursor = "pointer";
image_div.onclick = function () {
new MyAlert().alert("系统提示","click the image_div",5000);
};
var outer_div = document.createElement("div");
outer_div.style.border = "1px solid red";
outer_div.style.width = parseInt(myInput.offsetWidth) + parseInt(image_div.style.width);
outer_div.style.height = myInput.offsetHeight;
document.body.appendChild(outer_div);
outer_div.appendChild(myInput);
outer_div.appendChild(image_div);
}
</script>
</head>
<body onload="bodyOnload()">
<input id="myInput" type="text" name="name" title="名字"/>
</body>
</html>
2.myAlert.js
/**
* Created by zhuwenqi on 2017/6/20.
*/
/**
* @param options 基本配置
* @constructor
*/
function MyAlert(options) {
this.options = options ;
}
/**
* 提示窗口
* @param title 提示标题,默认为""
* @param content 提示内容,默认为""
* @param closeTime 提示窗口自动关闭时间,单位为ms,默认为2000ms
*/
MyAlert.prototype.alert = function (title,content,closeTime) {
var div_background = document.createElement("div");
div_background.style.position = "absolute";
div_background.style.left = "0";
div_background.style.top = "0";
div_background.style.width = "100%";
div_background.style.height = "100%";
div_background.style.backgroundColor = "rgba(0,0,0,0.1)";
div_background.style.zIndex = "1001";
var div_alert = document.createElement("div");
div_alert.style.position = "absolute";
div_alert.style.left = "40%";
div_alert.style.top = "0";
div_alert.style.width = "20%";
div_alert.style.height = "20%";
div_alert.style.overflow = "auto";
div_alert.style.backgroundColor = "rgba(255,255,255,0.5)";
div_alert.style.zIndex = "1002";
div_alert.style.border = "1px solid blue";
div_alert.style.borderRadius = "10px";
div_alert.style.boxShadow = "0 0 10px gray";
var div_title = document.createElement("div");
div_title.style.backgroundColor = "rgba(0,255,0,0.3)";
div_title.style.textAlign = "center";
var span_title = document.createElement("span");
span_title.style.fontSize = "20px";
span_title.style.fontWeight = "bold";
var text_title = document.createTextNode((title === undefined || title === null) ? "" : title) ;
span_title.appendChild(text_title);
div_title.appendChild(span_title);
div_alert.appendChild(div_title);
var div_content = document.createElement("div");
div_content.style.lineHeight = "35px";
div_content.style.paddingLeft = "10px";
var span_content = document.createElement("span");
var text_content = document.createTextNode((content === undefined || content === null) ? "" : content);
span_content.appendChild(text_content);
div_content.appendChild(span_content);
div_alert.appendChild(div_content);
document.body.appendChild(div_background);
document.body.appendChild(div_alert);
setTimeout(function () {
document.body.removeChild(div_alert);
document.body.removeChild(div_background);
},(closeTime === undefined || closeTime === null || closeTime === "") ? 2000 : closeTime);
};
html5+css3+javascript 自定义提示窗口的更多相关文章
- html5+css3+javascript 自定义弹出窗口
效果图: 源码: 1.demo.jsp <%@ page contentType="text/html;charset=UTF-8" language="java& ...
- HTMl5/CSS3/Javascript 学习推荐资源
HTMl5/CSS3/Javascript 学习推荐资源 前端的定义应该是数据内容的展示,在国内大家都觉得前端只是HTML+CSS+Javascript,但是实际上与展示有关的都是前端,所以Ruby/ ...
- HTML5&CSS3&JavaScript&PHP&MySQL学习笔记
1.在文字间添加一条水平线 使用<hr /> 注意该符号不是成对出现的 2.<q> </q>用来标记于段落中的较短引用,浏览器会在它之间的语句两端加上双引号. ...
- 检测 HTML5\CSS3\JAVASCRIPT 在浏览器的适应情况
CSS3 Selectors Test : 这是CSS3.INFO网站提供的css选择器测试页面,它能够详细显示当前浏览器对所有CSS3选择器的支持情况.启动测试,浏览器会自动测验,并已列表的方式显示 ...
- HTML5 + CSS3 + JavaScript
http://www.programmer.com.cn/14761/#more-14761 文/李晶 随着互联网产业的爆炸式增长,与之伴生的Web前端技术也在历经洗礼和蜕变.尤其是近几年随着移动终端 ...
- 《HTML5+CSS3+JavaScript 从入门到精通(标准版)》学习笔记(二)
这是一个应用的例子,学以致用嘛 <!--这些代码我就直接放在了博客园的"页首Html代码"中,用于自定义博客,效果就是页面左上角的白色文字--> <p> & ...
- 《HTML5+CSS3+JavaScript 从入门到精通(标准版)》学习笔记(一)
以下是以代码形式书写的笔记,本系列会持续更新,主要内容预计是类似下文的笔记,兼或一些思考与小项目,希望对你会有所帮助 1 <!-- --> <!DOCTYPE html>< ...
- 用HTML5/CSS3/JS开发Android/IOS应用框架大全
现在人人都想成为安卓/IOS应用开发工程师.其实,安卓/IOS应用可以用很多种语言来实现.由于我们前端开发工程师,对HTML5/CSS/JavaScript的网络编程已经相当熟悉了.所以,今天大家将会 ...
- 好程序员技术分享html5和JavaScript的区别
好程序员技术分享html5和JavaScript的区别,HTML5广义上讲是前端开发学科的代名词,包含HTML5.CSS3及JavaScript三个重要的部分,是运行在浏览器上应用的统称.如PC端网站 ...
随机推荐
- Laravel-事件简单使用
Laravel-事件简单使用 标签(空格分隔): php, laravel 注册事件和监听器 生成事件和监听器:php artisan event:generate key => 事件 valu ...
- JS实现掷骰子
JS实现掷骰子 实现方法: 方法一:通过background-position.background-image.backg-repeat三个属性以及jquery animate()方法改变背景骰子图 ...
- 分享一个完美的新闻客户端(酷商城)Android源码
分享一个完美的新闻客户端(酷商城)Android源码,这个源码项目是从安卓教程网转载过来的,项目主要是解析html,fragment,异步缓存图片加载,webview加载网页等.可以正常的运行的,我已 ...
- oracle导入导出操作
1,获取oracle导入导出帮助: imp help=y 2,导出命令 exp 用户名/密码@数据库实例 file=文件路径名 如: exp sys/password@orcl file=d:\dat ...
- 记录——本地minikube安装ubuntu镜像总是报 Back-off restarting failed container问题 -已解决(更新)
1.环境介绍 使用本机系统:macX minikube镜像:安装的阿里云提供的镜像(否则总是提示访问google的api,不FQ无法成功) 虚拟机情况:使用Virtual box 的虚拟机环境 min ...
- How Google Backs Up The Internet Along With Exabytes Of Other Data
出处:http://highscalability.com/blog/2014/2/3/how-google-backs-up-the-internet-along-with-exabytes-of- ...
- Vue学习之路第七篇:跑马灯项目实现
前面六篇讲解了Vue的一些基础知识,正所谓:学以致用,今天我们将用前六篇的基础知识,来实现类似跑马灯的项目. 学前准备: 需要掌握定时器的两个函数:setInterval和clearInterval以 ...
- HDU 1005 Number Sequence(找规律)
链接:传送门 题意:略 思路:f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7 -> f(n) = (A * f(n-1)%7 + B * f(n-1)%7) ...
- Python字典嵌套
import copy menu = { "计算机科学与技术":{ "程序编程":{ "传统语言":{ "C++":&q ...
- POJ——T2186 Popular Cows || 洛谷——P2341 [HAOI2006]受欢迎的牛
http://poj.org/problem?id=2186 || https://www.luogu.org/problem/show?pid=2341 Time Limit: 2000MS M ...