|
很多gm在开区时候都想把自己的游戏网站尽量弄得更漂亮,更完美一点。今天我是有备而来的,给大家分享一份右下角漂浮代码。
代码效果图:
说明:随着网站下拉紧贴右下角滚动的。
代码如下:
- <script language="javascript">
- document.write('<div id="china_ads_div405" style="width:270px">');
- document.write('<div><a href="你的登陆器下载链接" target="_blank"><img src="images/dlqxz.jpg" width="270" height="93" border="0"></a></div>');
- document.write('<div><a href="你的补丁下载链接" target="_blank"><img src="images/bdxz.jpg" width="270" height="93" border="0"></a></div>');
- document.write('</div>');
- var Class = {
- create: function() {
- return function() {
- this.initialize.apply(this, arguments);
- }
- }
- }
- Function.prototype.bind = function() {
- var __method = this, args = $A(arguments), object = args.shift();
- return function() {
- return __method.apply(object, args.concat($A(arguments)));
- }
- }
- var $A = Array.from = function(iterable) {
- if (!iterable) return [];
- if (iterable.toArray) {
- return iterable.toArray();
- } else {
- var results = [];
- for (var i = 0; i < iterable.length; i++)
- results.push(iterable[i]);
- return results;
- }
- }
- var Float = Class.create();
- Float.prototype = {
- initialize: function(elem, options) {
- this.toDo = options.toDo || function(){},
- this.bodyScrollTop = document.documentElement.scrollTop || document.body.scrollTop,
- this.bodyScrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft,
- this.element = document.getElementById(elem);
- this.dely = options.dely || 500;
- this.top = options.top || 0;
- this.left = options.left || 0;
- },
- start:function(){
- if(!this.element){
- alert('please set a element first!');
- return false;
- }
- this.element.style.position = 'absolute';
- this.toDo();
- setInterval(this.toDo.bind(this),this.dely)
- }
- }
- var f = new Float('china_ads_div405',{dely:100,
- toDo:function(){
- var isIE = document.all && window.external;
- this.bodyScrollTop = document.documentElement.scrollTop || document.body.scrollTop;
- this.bodyScrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
- if(isIE){
- this.docWidth = document.documentElement.clientWidth || document.body.clientWidth;
- this.docHeight = document.documentElement.clientHeight || document.body.clientHeight;
- }else{
- this.docWidth = (document.body.clientWidth > document.documentElement.clientWidth)?document.documentElement.clientWidth:document.body.clientWidth;
- this.docHeight = (document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight;
- }
- this.element.style.top = (this.docHeight - parseInt(this.element.offsetHeight,10)) + parseInt(this.bodyScrollTop, 10)+ 'px';
- this.element.style.left = (this.docWidth - parseInt(this.element.offsetWidth,10)) + parseInt(this.bodyScrollLeft, 10) + 'px';
- }
- });
- f.start();
- </script>
复制代码 最后附上2个小图片,当然你也可以根据自己需求来设计一个。
|
|