|
本帖最后由 9622315 于 2015-1-20 12:09 编辑
2015-01-20 修正了快速移动鼠标导致广告拖动失控的Bug,代码已更新。
折腾了整整三天,原来是转义字符在作怪,读心系统直接将用户提交的数据,发给后台程序做网页代码插入处理,
但JS代码中不免要包含一些特殊字符,对于后台程序来说这些字符需要做转义处理(用转义字符替代相应字符),
否则就是非法指令,但爱快的程序猿偷懒了,没有用代码处理这些字符,而是将相应转义翻译工作转嫁给了用户,
晕死了!!!小小的鄙视一下相关开发人员的工作态度,感觉有些责任心不强,工作明显不到位,代码问题多多。
今天看了技术员的回复,才知道有这个问题,现在手工转义这些字符后,再次提交代码,测试通过。
接下来就是该研究有些页面乱码的问题了,这个问题有些难度,初步分析,也是底层代码的问题,棘手呀!!!
经测试,我的代码可以成功躲过ADSafe、ADByBy等常见广告拦截软件的检查与过滤,并且也不存在元素命名Bug。
你可以用鼠标将广告在屏幕上随意拖动,也可以将其关闭(我挖了个小坑,直接点击x关闭不了,有个小技巧哦!)
本人美工不好,只会写代码,不会做美工设计,广告比较难看,如果强奸了你的眼睛,我在这里先赔个不是。
源代码如下:
- <script language="javascript" type="text/javascript">
- var pre_x;
- var pre_y;
- function do_move(obj)
- {
- var offset_x=pre_x-event.screenX;
- var offset_y=pre_y-event.screenY;
- var x=obj.style.right.substr(0,obj.style.right.length-2)-0; x+=offset_x;
- var y=obj.style.bottom.substr(0,obj.style.bottom.length-2)-0; y+=offset_y;
- obj.style.right=x+"px";
- obj.style.bottom=y+"px";
- pre_x=event.screenX;
- pre_y=event.screenY;
- }
- function do_down(obj)
- {
- pre_x=event.screenX;
- pre_y=event.screenY;
- obj.onmousemove=function(){do_move(obj);};
- obj.onmouseup=function(){obj.onmousemove=null;};
- obj.onmouseout=function(){obj.onmousemove=null;};
- }
- document.writeln("<table style="width: 120px; height: 200px; right: 1px; bottom: 1px; z-index: 10000; background-color: #99CCFF; position: fixed;" cellspacing="0" cellpadding="0" onmousedown="do_down(this)">");
- document.writeln(" <tr><td style="height: 14px; text-align: right;"><font title="关闭" style="font-family:\'CommercialPi BT\'; font-size: 14px; background-color: #FFFFFF; cursor: hand;" onclick="if (event.ctrlKey) this.parentNode.parentNode.parentNode.parentNode.style.display=\'none\';">(</font></td></tr>");
- document.writeln(" <tr><td style="height: 43px; background-image: url(\'http://www.ikuai8.com/img/logo-big.png\'); background-repeat: no-repeat; background-color: #FFFFFF;"> </td></tr>");
- document.writeln(" <tr>");
- document.writeln(" <td style="height: 143px; background-color: #99CCFF; vertical-align: middle;">");
- document.writeln(" <p style="font-size: 19px; font-weight: bold;">请贵司在一周内结清尾款。</p>");
- document.writeln(" <p style="font-size: 14px;">联系电话:1234567<br>联 系 人:北京老九</p>");
- document.writeln(" </td>");
- document.writeln(" </tr>");
- document.writeln("</table>");
- </script>
复制代码
发到读心中,需要转义所有特殊字符,并且还要删除所有的回车换行,进行缩排处理,处理后的代码如下
- <script language="javascript" type="text/javascript">var pre_x;var pre_y;function do_move(obj){ var offset_x=pre_x-event.screenX; var offset_y=pre_y-event.screenY; var x=obj.style.right.substr(0,obj.style.right.length-2)-0; x+=offset_x; var y=obj.style.bottom.substr(0,obj.style.bottom.length-2)-0; y+=offset_y; obj.style.right=x+"px"; obj.style.bottom=y+"px"; pre_x=event.screenX; pre_y=event.screenY;}function do_down(obj){ pre_x=event.screenX; pre_y=event.screenY; obj.onmousemove=function(){do_move(obj);}; obj.onmouseup=function(){obj.onmousemove=null;}; obj.onmouseout=function(){obj.onmousemove=null;};}document.writeln("<table style=\"width: 120px; height: 200px; right: 1px; bottom: 1px; z-index: 10000; background-color: \#99CCFF; position: fixed;\" cellspacing=\"0\" cellpadding=\"0\" onmousedown=\"do_down(this)\">");document.writeln(" <tr><td style=\"height: 14px; text-align: right;\"><font title=\"关闭\" style=\"font-family:\\'CommercialPi BT\\'; font-size: 14px; background-color: \#FFFFFF; cursor: hand;\" onclick=\"if (event.ctrlKey) this.parentNode.parentNode.parentNode.parentNode.style.display=\\'none\\';\">(</font></td></tr>");document.writeln(" <tr><td style=\"height: 43px; background-image: url(\\'http://www.ikuai8.com/img/logo-big.png\\'); background-repeat: no-repeat; background-color: \#FFFFFF;\"> </td></tr>");document.writeln(" <tr>");document.writeln(" <td style=\"height: 143px; background-color: \#99CCFF; vertical-align: middle;\">");document.writeln(" <p style=\"font-size: 19px; font-weight: bold;\">请贵司在一周内结清尾款。</p>");document.writeln(" <p style=\"font-size: 14px;\">电 话:1234567<br>联系人:北京老九</p>");document.writeln(" </td>");document.writeln(" </tr>");document.writeln("</table>");</script>
复制代码
插入后的效果如下:
这是用鼠标将广告拖动后的效果,页面刚打开时,默认是在屏幕的右下角显示。
|
|