|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
ps.本想发在作品展示的,结果刚才那个帖子点错了,发在了技术交流里,在这里重新写上
为什么说他超超超级简单呢?因为今天编程时间有限,只能编半小时,我就用15分钟时间做了这个65行的程序,话不多说,上代码:
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>表白程序</title>
- <script type="text/javascript">
- window.onload = function (){
- Exe.run();
- }
-
- var Exe = {
- run : function (){
- this.init();
- },
-
- init : function (){
- document.body.style.cssText = ' background: lightpink; text-align: center;'
-
- var title = document.createElement( 'h3' );
- title.innerHTML = '小姐姐,你喜欢我吗?';
- title.style.cssText = 'color: orange;';
-
- document.body.appendChild( title );
-
- var buttons = [ null , null ];
- var pos = ['50%', '5%'];
-
- buttons[0] = document.createElement('input');
- buttons[0].type = 'button';
- buttons[0].value = '不喜欢';
- buttons[0].style.cssText = 'position: absolute; background: red; border: none; width: 40%; height: 30%; left: ' + pos[0];
-
- buttons[1] = document.createElement('input');
- buttons[1].type = 'button';
- buttons[1].value = '喜欢';
- buttons[1].style.cssText = 'position: absolute; background: green; border: none; width: 40%; height: 30%; left: ' + pos[1];
-
- document.body.appendChild( buttons[0] );
- document.body.appendChild( buttons[1] );
-
- buttons[0].onmouseover = function (){
- buttons[0].style.left = pos[1];
- buttons[1].style.left = pos[0];
- }
-
- buttons[1].onmouseout = function (){
- buttons[0].style.left = pos[0];
- buttons[1].style.left = pos[1];
- }
-
- buttons[1].onmousedown = function (){
- var thing = (confirm('我就知道你会喜欢我^_^,咱们要不要就成最好的朋友?'));
-
- while (!thing) {
- thing = confirm('你肯定是眼花了,再问一遍:咱们要不要就成最好的朋友?');
- }
- alert('好的,我们以后就是最好的朋友了^_^');
- }
- }
- };
- </script>
- </head>
- <body></body>
- </html>
复制代码
我15分钟才做出个这玩意,我太菜了,哪位大神能帮我改进一下 |
|