discuz快速复制/复制链接增强,优化FLASH复制
discuz的链接复制是基于flash的,现在很多浏览器都放弃了flash,因此需要修改!其实也非常简单,只需要找到你的帖子页面模板(如何找位置请参考利用审查元素这个神器去修改任何想要修改的网页图片或者元素 ),在文件底部加上如下代码:<script type="text/javascript">function copyThreadUrl(obj, bbname) { bbname = bbname || SITEURL; freeaddon_copythreadurl_setCopy($('thread_subject').innerHTML.replace(/&/g, '&') + '\n' + obj.href + '\n' + '(出处: '+bbname+')' + '\n', '帖子地址已经复制到剪贴板'); return false;}function freeaddon_copythreadurl_setCopy(text, msg){ text = text.replace(/[\xA0]/g, ' '); if(BROWSER.ie) { var r = clipboardData.setData('Text', text); if(r) { if(msg) { showPrompt(null, null, '<span>' + msg + '</span>', 1500); } } else { showDialog('<div class="c"><div style="width: 200px; text-align: center;">复制失败,请选择“允许访问”</div></div>', 'alert'); } } else { var success = false; try { var cp = document.createElement('textarea'); cp.style.fontSize = '12pt'; cp.style.border = '0'; cp.style.padding = '0'; cp.style.margin = '0'; cp.style.position = 'absolute'; cp.style.left = '-9999px'; var yPosition = window.pageYOffset || document.documentElement.scrollTop; cp.style.top = yPosition + 'px'; cp.setAttribute('readonly', ''); cp.value = text; $('append_parent').appendChild(cp); cp.select(); cp.setSelectionRange(0, cp.value.length); var success = document.execCommand('copy', false, null); $('append_parent').removeChild(cp); } catch (e) { var success = false; } if(success) { if(msg) { showPrompt(null, null, '<span>' + msg + '</span>', 1500); } } else { var msg = '<div class="c"><div style="width: 200px; text-align: center; text-decoration:underline;">点此复制到剪贴板</div>' + AC_FL_RunContent('id', 'clipboardswf', 'name', 'clipboardswf', 'devicefont', 'false', 'width', '200', 'height', '40', 'src', STATICURL + 'image/common/clipboard.swf', 'menu', 'false','allowScriptAccess', 'sameDomain', 'swLiveConnect', 'true', 'wmode', 'transparent', 'style' , 'margin-top:-20px') + '</div>'; showDialog(msg, 'info'); CLIPBOARDSWFDATA = text; } }}</script>保存更新缓存即可!效果如下图:
页:
[1]