腾讯首页上扒出来的。1.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html >
<head>
<title></title>
</head>
<body>
8秒后开启
<div id="QQ_Full" style="width:910px; margin:0 auto; display:none;"></div>
显示8秒后关闭
<script src="http://adsfile.qq.com/web/AD2v1.7.6.js" type="text/javascript"></script>
<script src="1.js"></script>
<script>AD2.render('QQ_Full')</script>
</body>
</html>
1.jsAD2.area({
id: 'QQ_Full'
})({
cid: '104923',
oid: '1129109',
display: 'fullscreen',
display_config: {
delay: 7,
duration: 7,
show_duration: .5,
hide_duration: .5
},
monitor_url: '',
fodder: [{
type: 'flash',
resource_url: 'http://adsfile.qq.com/web/byqpg_0619.swf',
link_to: 'http://www.163.com',
width: 910,
height: 500,
cover: false
}]
});
上面1.htm和1.js。可以实现滚动效果。问题:
删除1.htm中第一句<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> 后,显示有问题。需要怎么改?(应该是改AD2v1.7.6.js)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html >
<head>
<title></title>
</head>
<body>
8秒后开启
<div id="QQ_Full" style="width:910px; margin:0 auto; display:none;"></div>
显示8秒后关闭
<script src="http://adsfile.qq.com/web/AD2v1.7.6.js" type="text/javascript"></script>
<script src="1.js"></script>
<script>AD2.render('QQ_Full')</script>
</body>
</html>
1.jsAD2.area({
id: 'QQ_Full'
})({
cid: '104923',
oid: '1129109',
display: 'fullscreen',
display_config: {
delay: 7,
duration: 7,
show_duration: .5,
hide_duration: .5
},
monitor_url: '',
fodder: [{
type: 'flash',
resource_url: 'http://adsfile.qq.com/web/byqpg_0619.swf',
link_to: 'http://www.163.com',
width: 910,
height: 500,
cover: false
}]
});
上面1.htm和1.js。可以实现滚动效果。问题:
删除1.htm中第一句<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> 后,显示有问题。需要怎么改?(应该是改AD2v1.7.6.js)
不能删,是文档类型定义,有了那个浏览器会严格地验证语法,更好地支持您的代码,从上面能够看出来你的代码必须要符合xhtml规范。这是不能删的,基本上现在只要是编辑器都能这段代码会自动加上的。呵呵,这是常识呀。要学习,看这儿:http://www.w3school.com.cn/dtd/index.asp
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
比较长.分块贴出
AD2v1.7.6.jsvar AD2 = {}; (function(a) {
var slice = Array.slice || (function() {
var _slice = Array.prototype.slice;
return function(arr) {
return _slice.apply(arr, _slice.call(arguments, 1))
}
})(),
getType = function(v) {
var s = typeof v;
if (s === 'object') {
if (v) {
if (typeof v.length === 'number') {
s = 'array'
}
} else {
s = 'null'
}
}
return s
},
contains = function(superset, subset) {
return ! find(subset,
function(v, k) {
var sv = superset[k];
if (sv !== v) {
if (typeof sv == 'object' && typeof v == 'object') {
return ! contains(sv, v)
} else {
return true
}
} else {
return false
}
})
},
equals = function(a, b) {
return contains(a, b) && contains(b, a)
},
isEmpty = function(o) {
var empty = true;
each(o,
function(v, k, _break) {
empty = false;
return _break
});
return empty
},
each = (function() {
var _break = {},
arr_fn = function(numerable, fn, bind) {
for (var i = 0,
len = numerable.length; i < len; i++) {
if (fn.call(bind, numerable[i], i, _break) == _break) {
return i
}
}
return - 1
},
iterator_type = {
'string': function(numerable, fn, bind) {
return arr_fn(numerable.split(''), fn, bind)
},
'array': arr_fn,
'number': function(numerable, fn, bind) {
for (var i = 0; i < numerable; i++) {
fn.call(bind, i, i)
//alert('n:'+numerable);
}
//alert('n:'+numerable);
},
'object': function(numerable, fn, bind) {
for (var i in numerable) {
if (numerable.hasOwnProperty(i)) {
if (fn.call(bind, numerable[i], i, _break) == _break) {
return i
}
}
}
return - 1
}
},
getIterator = function(o) {
return iterator_type[getType(o)]
};
return function(numerable, fn, bind) {
return getIterator(numerable)(numerable, fn, bind || numerable)
}
})(),
find = function(numerable, fn, bind) {
var index = each(numerable,
function(v, k, _break) {
if (fn.apply(bind, arguments) === true) {
return _break
}
});
return index == -1 ? null: numerable[index]
},
filter = function(numerable, fn, bind) {
var valids = [];
each(numerable,
function(v) {
if (fn.apply(bind, arguments) === true) {
valids.push(v)
}
});
return valids
},
map = function(numerable, fn, bind, is_dictionary) {
var results;
if (is_dictionary) {
results = {};
each(numerable,
function(v, k) {
results[k] = fn.apply(bind, arguments)
})
} else {
results = [];
each(numerable,
function() {
results.push(fn.apply(bind, arguments))
})
}
return results
},
invoke = function(numerable, method_name, arg1, arg2, argN) {
var args = slice(arguments, 2);
each(numerable,
function(v, k) {
v[method_name].apply(v, args)
})
},
unlink = function(object) {
if (object == null) {
return object
}
if (typeof object.length == 'number' && typeof object != 'string') {
return map(object, unlink)
} else if (typeof object == 'object') {
return map(object, unlink, null, true)
}
return object
},
mixdeep = function(r) {
if (!r) {
r = {}
}
for (var i = 1; i < arguments.length; i++) {
var s = arguments[i];
if (s) {
for (var j in s) {
if (r[j] && typeof r[j] == 'object' && typeof s[j] == 'object') {
arguments.callee(r[j], s[j])
} else {
r[j] = unlink(s[j])
}
}
}
}
return r
},
mix = function(r) {
if (!r) {
r = {}
}
for (var i = 1; i < arguments.length; i++) {
var s = arguments[i];
if (s) {
for (var j in s) {
r[j] = s[j]
}
}
}
return r
},
mixif = function(r) {
if (!r) {
r = {}
}
for (var i = 1; i < arguments.length; i++) {
var s = arguments[i];
if (s) {
for (var j in s) {
if (r[j] === undefined) {
r[j] = s[j]
}
}
}
}
return r
},
generateId = (function() {
var id = 1;
return function() {
return 'auto_gen_' + id++
}
})(),
Class = {
proto: (function() {
var fn = function(instance, method) {
return this.prototype[method].apply(instance, slice(arguments, 2))
};
return function(ctor) {
ctor.proto = fn
}
})(),
create: function(proto, sp) {
var ctor = function() {
if (this.init) {
this.init.apply(this, arguments)
}
};
var mixins_begin_index = 1;
if (sp && typeof sp == 'function') {
var F = function() {};
ctor.superclass = F.prototype = sp.prototype;
ctor.prototype = new F();
mixins_begin_index = 2
}
var mixins = slice(arguments, mixins_begin_index);
mixins.unshift(proto);
mix(ctor.prototype, mixif.apply(window, mixins));
return ctor
}
},
getObjectToStringFn = function(assign_token, pair_separator, need_last, need_encode) {
var encode = need_encode ? encodeURIComponent: function(k) {
return k
};
return function(o) {
return map(o,
function(v, k) {
if (k != null) {
return k + assign_token + encode(v)
}
}).join(pair_separator) + (need_last ? pair_separator: '')
}
};
mix(a, {
generateId: generateId,
slice: slice,
getType: getType,
Object: {
equals: equals,
isEmpty: isEmpty
},
each: each,
map: map,
find: find,
filter: filter,
mix: mix,
mixdeep: mixdeep,
mixif: mixif,
indexOf: function(arr, o) {
if (arr.indexOf) {
return arr.indexOf(o)
}
for (var i = 0; i < arr.length; i++) {
if (arr[i] === o) {
return i
}
}
return - 1
},
buffer: function(runner, delay) {
if (!delay) {
return runner
}
var timer;
return function() {
if (timer) {
clearTimeout(timer)
}
var args = arguments;
timer = setTimeout(function() {
runner.apply(window, args)
},
delay || 100)
}
},
Class: Class,
format: function(s, config, reserve) {
return s.replace(/\{([^}]*)\}/g, (typeof config == 'object') ?
function(m, i) {
var ret = config[i];
return ret == null && reserve ? m: ret
}: config)
},
getObjectToStringFn: getObjectToStringFn,
serializeStyles: getObjectToStringFn(':', ';', true, false),
serializeAttrs: getObjectToStringFn('=', ' ', true, false),
serializeQuery: getObjectToStringFn('=', '&', false, true)
})
})(AD2); (function(a) {
var EVT = '__events',
FNID = '__fnid',
each = a.each,
deleteHandler = function(handlers, k) {
var handler = handlers[k];
if (handler) {
delete handler.fn;
delete handler.bind;
delete handlers[k]
}
},
deleteEvent = function(events, type, handlers) {
handlers = handlers || events[type];
if (handlers) {
each(handlers,
function(v, k) {
deleteHandler(handlers, k)
});
delete events[type]
}
},
deletePropIfEmpty = function(o, prop) {
var op = o[prop];
for (var p in op) {
if (op.hasOwnProperty(p)) {
return
}
}
delete o[prop]
},
getProp = function(o) {
for (var i = 1,
ret = o; i < arguments.length; i++) {
var prop = arguments[i];
ret = ret[prop] = (ret[prop] || {})
}
return ret
},
on = function(o, type, fn, bind) {
getProp(o, EVT, type)[fn[FNID] || (fn[FNID] = a.generateId())] = {
fn: fn,
bind: bind || o
}
},
batch = function(o, handlers) {
each(handlers,
function(v, k) {
if (typeof v == 'function') {
on(o, k, v)
} else {
on(o, k, v.fn, v.bind)
}
})
};
a.Observable = {
fire: function(type) {
this._fire(type, a.slice(arguments, 1))
},
_fire: function(type, args) {
var events = this[EVT];
if (events) {
var event = events[type];
if (event) {
each(event,
function(handler) {
handler.fn.apply(handler.bind, args)
})
}
}
},
on: function(type, fn, bind) {
if (arguments.length == 1) {
batch(this, type)
} else {
on(this, type, fn, bind)
}
},
un: function(type, fn) {
var events = this[EVT];
if (!events) {
return
}
if (type) {
var event = events[type];
if (event) {
if (fn) {
if (fn[FNID]) {
deleteHandler(event, fn[FNID]);
deletePropIfEmpty(events, type)
}
} else {
deleteEvent(events, type)
}
deletePropIfEmpty(this, EVT)
}
} else {
each(events,
function(v, k) {
deleteEvent(events, k, v)
});
delete this[EVT]
}
}
}
})(AD2); (function(a) {
var el_template = '<{tag} {attrs}style="{styles}">{inner}</{tag}>',
each = a.each,
propertyCache = {},
patterns = {
HYPHEN: /(-[a-z])/i,
ROOT_TAG: /^body|html$/i
},
ua = (function() {
var o = {
ie: 0,
opera: 0,
gecko: 0, webkit: 0,
mobile: null
};
var ua = navigator.userAgent,
m;
if ((/KHTML/).test(ua)) {
o.webkit = 1
}
m = ua.match(/AppleWebKit\/([^\s]*)/);
if (m && m[1]) {
o.webkit = parseFloat(m[1]);
if (/ Mobile\//.test(ua)) {
o.mobile = "Apple"
} else {
m = ua.match(/NokiaN[^\/]*/);
if (m) {
o.mobile = m[0]
}
}
}
if (!o.webkit) {
m = ua.match(/Opera[\s\/]([^\s]*)/);
if (m && m[1]) {
o.opera = parseFloat(m[1]);
m = ua.match(/Opera Mini[^;]*/);
if (m) {
o.mobile = m[0]
}
} else {
m = ua.match(/MSIE\s([^;]*)/);
if (m && m[1]) {
o.ie = parseFloat(m[1])
} else {
m = ua.match(/Gecko\/([^\s]*)/);
if (m) {
o.gecko = 1;
m = ua.match(/rv:([^\s\)]*)/);
if (m && m[1]) {
o.gecko = parseFloat(m[1])
}
}
}
}
}
return o
})();
var walk = function(el, side) {
for (var nel = el; nel; nel = nel[side]) {
if (nel.nodeType == 1) {
return nel
}
}
},
buildHTML = function(styles, attrs, tag, inner) {
return a.format(el_template, {
tag: tag || 'div',
attrs: a.serializeAttrs(attrs || {}),
styles: a.serializeStyles(styles),
inner: inner || ''
})
},
toCamel = function(property) {
if (!patterns.HYPHEN.test(property)) {
return property
}
if (propertyCache[property]) {
return propertyCache[property]
}
var converted = property;
while (patterns.HYPHEN.exec(converted)) {
converted = converted.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase())
}
propertyCache[property] = converted;
return converted
},
locus = function(dest, now, n) {
var d = Math.abs(dest - now);
if (d < n) {
return arguments.callee(dest, now, d / 2)
}
return n <= 1 ? dest: (dest + (n - 1) * now) / n
},
getStyle = (function() {
if (document.defaultView && document.defaultView.getComputedStyle) {
return function(el, property) {
var value = null;
if (property == 'float') {
property = 'cssFloat'
}
var computed = document.defaultView.getComputedStyle(el, '');
if (computed) {
value = computed[toCamel(property)]
}
return el.style[property] || value
}
} else if (document.documentElement.currentStyle && ua.ie) {
return function(el, property) {
switch (toCamel(property)) {
case 'opacity':
var val = 100;
try {
val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity
} catch(e) {
try {
val = el.filters('alpha').opacity
} catch(e) {}
}
return val / 100;
case 'float':
property = 'styleFloat';
default:
var value = el.currentStyle ? el.currentStyle[property] : null;
return (el.style[property] || value)
}
}
} else {
return function(el, property) {
return el.style[property]
}
}
})(),
setStyle2 = (function() {
var px = /left|top|right|bottom|width|height/;
var transVal = function(k, v) {
if (px.test(k) && typeof v == 'number') {
v = v + 'px';
}
/*
if(v=='917px')
{
v='0'
}
alert("v:"+v);
*/
return v
};
if (ua.ie) {
return function(el, property, val) {
property = toCamel(property);
switch (property) {
case 'opacity':
el.style.filter = 'alpha(opacity=' + val * 100 + ')';
if (!el.currentStyle || !el.currentStyle.hasLayout) {
el.style.zoom = 1
}
break;
case 'float':
property = 'styleFloat';
default:
el.style[property] = transVal(property, val)
}
}
} else {
return function(el, property, val) {
property = toCamel(property);
if (property == 'float') {
property = 'cssFloat'
}
el.style[property] = transVal(property, val)
}
}
})(),
setStyle = function(el, k, v) {
el = $(el);
if (typeof k == 'object') {
each(k,
function(_v, _k) {
setStyle2(el, _k, _v)
})
} else {
setStyle2(el, k, v)
}
},
getDocumentScrollLeft = function(doc) {
doc = doc || document;
return Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft)
},
getDocumentScrollTop = function(doc) {
doc = doc || document;
return Math.max(doc.documentElement.scrollTop, doc.body.scrollTop)
},
getDocumentHeight = function() {
var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight: document.documentElement.scrollHeight;
var h = Math.max(scrollHeight, getViewportHeight());
return h
},
getDocumentWidth = function() {
var scrollWidth = (document.compatMode != 'CSS1Compat') ? document.body.scrollWidth: document.documentElement.scrollWidth;
var w = Math.max(scrollWidth, getViewportWidth());
return w
},
getViewportHeight = function() {
var height = self.innerHeight;
var mode = document.compatMode;
if ((mode || ua.ie) && !ua.opera) {
height = (mode == 'CSS1Compat') ? document.documentElement.clientHeight: document.body.clientHeight
}
return height
},
getViewportWidth = function() {
var width = self.innerWidth;
var mode = document.compatMode;
if (mode || ua.ie) {
width = (mode == 'CSS1Compat') ? document.documentElement.clientWidth: document.body.clientWidth
}
return width
},
getXY = function(el) {
var pos = [el.offsetLeft, el.offsetTop];
var parentNode = el.offsetParent;
var accountForBody = (ua.webkit && getStyle(el, 'position') == 'absolute' && el.offsetParent == el.ownerDocument.body);
if (parentNode != el) {
while (parentNode) {
pos[0] += parentNode.offsetLeft;
pos[1] += parentNode.offsetTop;
if (!accountForBody && ua.webkit && getStyle(parentNode, 'position') == 'absolute') {
accountForBody = true
}
parentNode = parentNode.offsetParent
}
}
if (accountForBody) {
pos[0] -= el.ownerDocument.body.offsetLeft;
pos[1] -= el.ownerDocument.body.offsetTop
}
parentNode = el.parentNode;
while (parentNode.tagName && !patterns.ROOT_TAG.test(parentNode.tagName)) {
if (getStyle(parentNode, 'display').search(/^inline|table-row.*$/i)) {
pos[0] -= parentNode.scrollLeft;
pos[1] -= parentNode.scrollTop
}
parentNode = parentNode.parentNode
}
return pos
},
$ = function(id) {
if (typeof id == 'string') {
return document.getElementById(id)
}
return id
},
copyCoordinates = function(me, coordinates) {
copyCoordinates2(me, coordinates, ['left', 'right', 'horzontal_center']);
copyCoordinates2(me, coordinates, ['top', 'bottom', 'vertical_center']);
a.each(['width', 'height'],
function(p) {
if (typeof coordinates[p] != 'undefined') {
me[p] = coordinates[p]
}
});
return me
},
copyCoordinates2 = function(me, coordinates, directions) {
var specified_prop_name, specified_prop_value;
a.each(directions,
function(direction) {
if (typeof coordinates[direction] != 'undefined') {
specified_prop_name = direction;
specified_prop_value = coordinates[direction]
}
});
if (specified_prop_name) {
a.each(directions,
function(direction) {
delete me[direction]
});
me[specified_prop_name] = specified_prop_value
}
};
a.DomUtil = {
ua: ua,
get: $,
buildHTML: buildHTML,
createElement: function(html) {
if (typeof html != 'string') {
html = buildHTML.apply(window, arguments)
}
var el = document.createElement('div');
el.innerHTML = html;
return el.firstChild
},
next: function(el) {
return walk(el, 'nextSibling')
},
pre: function(el) {
return walk(el, 'previousSibling')
},
children: function(el) {
var results = [];
for (var cel = el.firstChild; cel; cel = cel.nextSibling) {
if (cel.nodeType == 1) {
results.push(cel)
}
}
return results
},
getSize: function(el) {
var old_display = getStyle(el, 'display');
if (old_display == 'none') {
setStyle(el, 'display', '')
}
var size = {
width: el.offsetWidth,
height: el.offsetHeight
};
setStyle(el, 'display', old_display);
return size
},
setStyle: setStyle,
getStyle: function(el, k) {
return getStyle($(el), k)
},
getXY: function(el) {
return getXY($(el))
},
hide: function(el) {
setStyle(el, 'display', 'none')
},
show: function(el) {
setStyle(el, 'display', 'block')
},
getDocumentHeight: getDocumentHeight,
getDocumentWidth: getDocumentWidth,
getViewportHeight: getViewportHeight,
getViewportWidth: getViewportWidth,
getDocumentScrollTop: getDocumentScrollTop,
getDocumentScrollLeft: getDocumentScrollLeft,
absolutize: function(el, zIndex, insert_to_body) {
el.className = 'absolute';
a.DomUtil.setStyle(el, {
position: 'absolute',
left: '-999px',
top: '-9999px',
zIndex: zIndex
});
if (insert_to_body) {
document.body.insertBefore(el, document.body.firstChild)
}
},
align: function(anchor, brick, type) {
anchor = $(anchor);
brick = $(brick);
var sizes = {},
types = type.split('-'),
anchorXY = getXY(anchor),
x = anchorXY[0],
y = anchorXY[1];
each({
anchor: anchor,
brick: brick
},
function(el, name) {
var o = sizes[name] = {};
each(['Width', 'Height'],
function(side) {
o[side.toLowerCase()] = el['offset' + side]
})
});
each(types[0].split(''),
function(al) {
switch (al) {
case 'r':
x += sizes.anchor.width;
break;
case 'b':
y += sizes.anchor.height;
break;
default:
break
}
});
each(types[1].split(''),
function(al) {
switch (al) {
case 'r':
x -= sizes.brick.width;
break;
case 'b':
y -= sizes.brick.height;
break;
default:
break
}
});
brick.style.left = x + 'px';
brick.style.top = y + 'px'
}
};
var FixedPosElement = a.Class.create({
interval: null,
init: function(el) {
this.el = el
},
destroy: function() {
this.fire('Destroy');
this.el.parentNode.removeChild(this.el)
}
},
a.Observable);
if (ua.ie == 6) {
a.DomUtil.FixedPosElement = a.Class.create({
init: function(el) {
FixedPosElement.prototype.init.apply(this, arguments);
el.style.position = 'absolute';
el.className = 'absolute'
},
setCoordinates: function(coordinates) {
copyCoordinates(this, coordinates);
var self = this;
var el = this.el;
var getLeft = (function() {
if (self.horzontal_center) {
return function() {
return (getViewportWidth() - self.width) / 2 + getDocumentScrollLeft()
}
}
if (self.left != undefined) {
return function() {
return getDocumentScrollLeft() + self.left
}
}
return function() {
return getDocumentScrollLeft() + getViewportWidth() - self.right - self.width
}
})();
var getTop = (function() {
if (self.vertical_center) {
return function() {
return (getViewportHeight() - self.height) / 2 + getDocumentScrollTop()
}
}
if (self.top != undefined) {
return function() {
return getDocumentScrollTop() + self.top
}
}
return function() {
return getDocumentScrollTop() + getViewportHeight() - self.bottom - self.height
}
})();