文章图片缩小放大功能增加: 先按住 CTRL 键再滑动鼠标中键放大缩小图片
功能说明:浏览带图片文章时,如果鼠标在图片上是,不小心想下拉网页时却放大图片,很不方便。
先按住CTRL键再滑动鼠标滚轮 进行图象放大/缩小"看图片文章的时候不用再把鼠标放到图片以外再下滑了。这样要复合个人上网习惯。
演示:http://slpd.net/Article/ShowInfo.asp?ID=2286
查 :ks_refreshcls.asp最后代码
<img src=$2 onclick=""javascript:window.open(this.src);"" style=""cursor: pointer"" alt=""点此在新窗口浏览图片"" onmousewheel=""return bbimg(this)"" onload=""javascript:resizepic(this)""
改为:
<IMG onmousewheel=""return imgzoom(this);"" onmouseover=""if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand';}"" onclick=""javascript:window.open(this.src);"" alt=""点击弹出新的窗口 CTRL+鼠标滚轮 进行图象放大/缩小"" src=$2 width=300 onload=""if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7;}"" border=0 resized=""true"">
兰色地方为图片初始大小。
JS文件,以下复制保存为common.js。
在文章内容页<SCRIPT src="common.js" type=text/javascript></SCRIPT>
var sPop = null;
var postSubmited = false;
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = (userAgent.indexOf('opera') != -1);
var is_saf = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
var is_webtv = (userAgent.indexOf('webtv') != -1);
var is_ie = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4 = ((is_ie) && (userAgent.indexOf('msie 4.') != -1));
var is_moz = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon = (userAgent.indexOf('konqueror') != -1);
var is_ns = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4 = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_mac = (userAgent.indexOf('mac') != -1);
function ctlent(event) {
if(postSubmited == false && (event.ctrlKey && event.keyCode == 13) || (event.altKey && event.keyCode == 83) && $('postsubmit')) {
if(in_array($('postsubmit').name, ['topicsubmit', 'replysubmit', 'editsubmit']) && !validate($('postform'))) {
return;
}
postSubmited = true;
$('postsubmit').disabled = true;
$('postform').submit();
}
}
function storeCaret(textEl){
if(textEl.createTextRange){
textEl.caretPos = document.selection.createRange().duplicate();
}
}
function checkall(form, prefix, checkall) {
var checkall = checkall ? checkall : 'chkall';
for(var i = 0; i < form.elements.length; i++) {
var e = form.elements[i];
if(e.name != checkall && (!prefix || (prefix && e.name.match(prefix)))) {
e.checked = form.elements[checkall].checked;
}
}
}
function arraypop(a) {
if(typeof a != 'object' || !a.length) {
return null;
} else {
var response = a[a.length - 1];
a.length--;
return response;
}
}
function arraypush(a, value) {
a[a.length] = value;
return a.length;
}
function findtags(parentobj, tag) {
if(typeof parentobj.getElementsByTagName != 'undefined') {return parentobj.getElementsByTagName(tag);}
else if(parentobj.all && parentobj.all.tags) {return parentobj.all.tags(tag);}
else {return null;}
}
function copycode(obj) {
var rng = document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
}
function toggle_collapse(objname, unfolded) {
if(typeof unfolded == 'undefined') {
var unfolded = 1;
}
var obj = $(objname);
var oldstatus = obj.style.display;
var collapsed = getcookie('discuz_collapse');
var cookie_start = collapsed ? collapsed.indexOf(objname) : -1;
var cookie_end = cookie_start + objname.length + 1;
obj.style.display = oldstatus == 'none' ? '' : 'none';
collapsed = cookie_start != -1 && ((unfolded && oldstatus == 'none') || (!unfolded && oldstatus == '')) ?
collapsed.substring(0, cookie_start) + collapsed.substring(cookie_end, collapsed.length) : (
cookie_start == -1 && ((unfolded && oldstatus == '') || (!unfolded && oldstatus == 'none')) ?
collapsed + objname + ' ' : collapsed);
expires = new Date();
expires.setTime(expires.getTime() + (collapsed ? 86400 * 30 : -(86400 * 30 * 1000)));
document.cookie = 'discuz_collapse=' + escape(collapsed) + '; expires=' + expires.toGMTString() + '; path=/';
var img = $(objname + '_img');
var img_regexp = new RegExp((oldstatus == 'none' ? '_yes' : '_no') + '\\.gif$');
var img_re = oldstatus == 'none' ? '_no.gif' : '_yes.gif'
if(img) {
img.src = img.src.replace(img_regexp, img_re);
}
}
function imgzoom(o) {
if(event.ctrlKey) {
var zoom = parseInt(o.style.zoom, 10) || 100;
zoom -= event.wheelDelta / 12;
if(zoom > 0) {
o.style.zoom = zoom + '%';
}
return false;
} else {
return true;
}
}
/*note BT >>>
*@模块: 客户端设置cookie
*@说明: 添加客户端设置,读取,加密,解密cookie一整套函数。
*/
function setcookie(name, value, expires, path, domain, secure) {
expires = expires ? expires : 86400;
var then = new Date();
then.setTime(then.getTime() + expires*1000);
expires = then.toGMTString();
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
/*note BT >>>
*@模块: 客户端读取cookie
*@说明: 添加客户端设置,读取,加密,解密cookie一整套函数。
*/
function getcookie(name) {
var cookie_start = document.cookie.indexOf(name);
var cookie_end = document.cookie.indexOf(";", cookie_start);
return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
}
/*note BT >>>
*@模块: 客户端编码cookie
*@说明: 浏览器利用javascript将汉字存入cookie的时候,被认为是多个字节,而javascript本身是UNICODE编码,一个汉字为一个字节,结果导致读取的时候为两个字节,而形成乱码。
*@注意: 存入的时候一个汉字被当作了三个字节,为UNICODE编码,高位在后,低位在前。
*/
function codecookie(str) {
var rs = "";
for(var i=str.length-1; i>=0;i--) {
rs += str.charCodeAt(i);
rs += i ? "d" : "";
}
return rs;
}
/*note BT >>>
*@模块: 客户端***cookie
*@说明: 将编码的cookie解回来,组成UNICODE字符。
*/
function decodecookie(str) {
var strarr;
var strrtn = "";
if(str == ""){
return "";
}
strarr=str.split("d");
for(var i=strarr.length-1; i>=0; i--) {
strrtn += String.fromCharCode(strarr[i]);
}
return strrtn;
}
function AddText(txt) {
obj = $('postform').message;
selection = document.selection;
checkFocus();
if(typeof(obj.selectionStart) != 'undefined') {
var opn = obj.selectionStart + 0;
obj.value = obj.value.substr(0, obj.selectionStart) + txt + obj.value.substr(obj.selectionEnd);
} else if(selection && selection.createRange) {
var sel = selection.createRange();
sel.text = txt;
sel.moveStart('character', -mb_strlen(txt));
} else {
obj.value += txt;
}
}
function insertAtCaret (textEl, text){
if(textEl.createTextRange && textEl.caretPos){
var caretPos = textEl.caretPos;
caretPos.text += caretPos.text.charAt(caretPos.text.length - 2) == ' ' ? text + ' ' : text;
} else if(textEl) {
textEl.value += text;
} else {
textEl.value = text;
}
}
function checkFocus() {
var obj = typeof wysiwyg == 'undefined' || !wysiwyg ? $('postform').message : editwin;
if(!obj.hasfocus) {
obj.focus();
}
}
function closesmiliewindow(e) {
if(typeof smiliewindow != 'undefined' && !smiliewindow.closed) {
smiliewindow.close();
}
}
function opensmiliewindow(width, height, editorid) {
smiliewindow = window.open('post.php?action=smilies' + (editorid ? '&editorid=' + editorid : ''), 'Popup', 'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes');
window.onunload = closesmiliewindow;
}
function mb_strlen(str) {
return (is_ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
}
function insertSmiley(smilieid) {
checkFocus();
var src = $('smilie_' + smilieid).src;
var code = $('smilie_' + smilieid).pop ? $('smilie_' + smilieid).pop : $('smilie_' + smilieid).alt;
if(typeof wysiwyg != 'undefined' && wysiwyg && allowsmilies && (!$('smileyoff') || $('smileyoff').checked == false)) {
if(is_moz) {
applyFormat('InsertImage', false, src);
var smilies = findtags(editdoc.body, 'img');
for(var i = 0; i < smilies.length; i++) {
if(smilies[i].src == src && smilies[i].getAttribute('smilieid') < 1) {
smilies[i].setAttribute('smilieid', smilieid);
smilies[i].setAttribute('border', "0");
}
}
} else {
insertText('<img src="' + src + '" border="0" smilieid="' + smilieid + '" alt="" /> ', false);
}
} else {
code += ' ';
AddText(code);
}
}
function announcement() {
$('announcement').innerHTML = '<marquee style="filter:progid:DXImageTransform.Microsoft.Alpha(startX=0, startY=0, finishX=10, finishY=100,style=1,opacity=0,finishOpacity=100); margin: 0px 8px" direction="left" scrollamount="2" scrolldelay="1" onMouseOver="this.stop();" onMouseOut="this.start();">' +
$('announcement').innerHTML + '</marquee>';
$('announcement').style.display = 'block';
}
function $(id) {
return document.getElementById(id);
}
function in_array(needle, haystack) {
if(typeof needle == 'string') {
for(var i in haystack) {
if(haystack[i] == needle) {
return true;
}
}
}
return false;
}
document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".cPopText { font-family: Tahoma, Verdana; background-color: #FFFFCC; border: 1px #000000 solid; font-size: 12px; padding-right: 4px; padding-left: 4px; line-height: 18px; padding-top: 2px; padding-bottom: 2px; visibility: hidden; filter: Alpha(Opacity=80)}");
document.write("</style>");
document.write("<div id='popLayer' style='position:absolute;z-index:1000' class='cPopText'></div>");
function showPopupText(event) {
if(event.srcElement) o = event.srcElement; else o = event.target;
if(!o) {
return;
}
MouseX = event.clientX;
MouseY = event.clientY;
if(o.alt != null && o.alt != '') {
o.pop = o.alt;
o.alt = '';
}
if(o.title != null && o.title != '') {
o.pop = o.title;
o.title = '';
}
if(o.pop != sPop) {
sPop = o.pop;
if(sPop == null || sPop == '') {
$('popLayer').style.visibility = "hidden";
} else {
popStyle = o.dyclass != null ? o.dyclass : 'cPopText';
$('popLayer').style.visibility = "visible";
showIt();
}
}
}
function showIt() {
$('popLayer').className = popStyle;
$('popLayer').innerHTML = sPop.replace(/<(.*)>/g,"<$1>").replace(/\n/g,"<br>");
var popWidth = $('popLayer').clientWidth;
var popHeight = $('popLayer').clientHeight;
var popLeftAdjust = MouseX + 12 + popWidth > document.body.clientWidth ? -popWidth - 24 : 0;
var popTopAdjust = MouseY + 12 + popHeight > document.body.clientHeight ? -popHeight - 24 : 0;
$('popLayer').style.left = (MouseX + 12 + document.body.scrollLeft + popLeftAdjust) + 'px';
$('popLayer').style.top = (MouseY + 12 + document.body.scrollTop + popTopAdjust) + 'px';
}
if(!document.onmouseover) {
document.onmouseover = function(e) {
var event = e ? e : window.event;
showPopupText(event);
};
}
代码演示打包
下载信息 [文件大小:241.08 KB 下载次数: 次] |
点击下载文件: |
[此贴子已经被作者于2006-10-30 3:54:16编辑过]