TA的每日心情 | 开心 2019-5-28 07:39 |
---|
签到天数: 339 天 [LV.8]以坛为家I
状元
- 积分
- 42284
|
2楼
楼主 |
发表于 2019-5-31 08:14:53
|
只看该作者
两个脚本代码,怎么样合并在一起?谢谢!
脚本一,现代汉语规范字典:
- window.onload=function(){
- JTsetup('x-hw');
- iterationSetup();
- specialSetup();
- };
- function specialSetup(){
- var _xa=document.querySelectorAll('x-a');
- if(!_xa[0]) return;
- for(var i=0; i<_xa.length; ++i)
- _xa[i].parentNode.setAttribute('x-meaning', '');
- }
- function iterationSetup(){
- var _hw=document.querySelectorAll('x-hw');
- if(_hw.length<2) return;
- for(var i=0; i<_hw.length; ++i){
- var _it=document.createElement('sup');
- _it.textContent=(i+1);
- _hw[i].appendChild(_it);
- }
- }
- function JTsetup(str){
- var _eles=document.querySelectorAll(str);
- if(_eles.length<2){
- if(!!_eles[0]){
- _eles[0].removeAttribute('onclick');
- }
- return;
- }
- for(var i=0; i<_eles.length; ++i){
- _eles[i].setAttribute('onclick', scrollPosition(_eles[i==_eles.length-1?0:i+1]));
- }
- }
- function scrollPosition(target){
- var _id=target.getAttribute('id');
- if(!_id){
- _id='random'+Math.round(Math.random()*1048576);
- target.setAttribute('id', _id);
- }
- if(!isBluedict())
- return "window.location.href='#"+_id+"'";
- return "window.location.href='entry://#"+_id+"'";
- }
- function isBluedict(){
- return !!document.querySelector('.bd_body');
- }
复制代码 脚本二,象形字典:
- window.onload = function(){
- if(document.getElementById("img_ysxs")){
- document.getElementById("img_ysxs").style.maxWidth="100%";
- document.getElementById("img_ysxs").onclick=function(){
- var now = document.getElementById ("img_ysxs");
- var i = now.style.maxWidth
- if(i=="100%"){document.getElementById("img_ysxs").style.maxWidth="none";}else{document.getElementById("img_ysxs").style.maxWidth="100%";}
- };
- };
- if(document.getElementById("img_zxyb")){
- document.getElementById("img_zxyb").style.maxWidth="100%";
- document.getElementById("img_zxyb").onclick=function(){
- var now = document.getElementById ("img_zxyb");
- var i = now.style.maxWidth
- if(i=="100%"){document.getElementById("img_zxyb").style.maxWidth="none";}else{document.getElementById("img_zxyb").style.maxWidth="100%";}
- };
- };
- };
复制代码
|
|