MozTW 討論區 https://forum.moztw.org/ |
|
JavaScript在Opera上的顯示問題 https://forum.moztw.org/viewtopic.php?f=13&t=17899 |
第 1 頁 (共 1 頁) |
發表人: | legnaleurc [ 2007-03-09, 03:46 ] |
文章主題 : | JavaScript在Opera上的顯示問題 |
首先請參照這個網頁: D&D dice roll 功能很簡單,就是擲骰子相加而已 要填的地方是骰子的個數 不過在Opera上,除了會出現一個叫'unknow thead'的警告外 在全部骰子和加總的那一格(也就是最下面的那格) 如果沒有用滑鼠選取的話,它的值不會更新 技術好一點還可以看到好幾個數字疊在一起 這是怎麼回事? 別問我為什麼會有$($(this).parentNode)這種東西 我還想問為什麼不這麼寫IE就不會過咧 |
發表人: | kourge [ 2007-03-09, 14:28 ] |
文章主題 : | |
caucAll( document.getElementsByClassName('dices') , document.getElementsByClassName('view') , document.getElementsByClassName('sumary') , $('total') ); 以上可以寫成: caucAll( $$('.dices'), $$('.view'), $$('.sumary'), $('total') ); 以下: function init() { if( location.pathname.search(/^\/(index\.html)?$/) >= 0 ) { for(var i=0 ; i < document.getElementsByClassName('stealth').length ; i++) { document.getElementsByClassName('stealth')[i].style['display']='none'; document.getElementsByClassName('detect')[i].innerHTML='<a title="展開隱藏區塊" onClick=" document.getElementsByClassName(\'stealth\')['+i+'].style[\'display\']=\'block\'; this.style.display=\'none\'; ">(繼續閱讀)</a>'; } } } 可以改成: function init() { if( location.pathname.search(/^\/(index\.html)?$/) >= 0 ) { $$('stealth').each(function(element, index) { element.hide(); $$('.detect')[index].update('<a title="展開隱藏區塊" onClick=" $$(\'.stealth\')['+i+'].show(); $(this).hide(); ">(繼續閱讀)</a>'); } } } 反正... document.getElementByClassName('blah') -> $$('.blah') for 迴圈 ->.each() element.innerHTML = 'blah' -> element.update('blah') new Array(1, 2, 3) -> [1, 2, 3] Opera 的錯誤是 unknown thread? |
發表人: | legnaleurc [ 2007-03-09, 17:47 ] |
文章主題 : | |
kourge 寫: caucAll( document.getElementsByClassName('dices') , document.getElementsByClassName('view') , document.getElementsByClassName('sumary') , $('total') );
以上可以寫成: caucAll( $$('.dices'), $$('.view'), $$('.sumary'), $('total') ); 以下: function init() { if( location.pathname.search(/^\/(index\.html)?$/) >= 0 ) { for(var i=0 ; i < document.getElementsByClassName('stealth').length ; i++) { document.getElementsByClassName('stealth')[i].style['display']='none'; document.getElementsByClassName('detect')[i].innerHTML='<a title="展開隱藏區塊" onClick=" document.getElementsByClassName(\'stealth\')['+i+'].style[\'display\']=\'block\'; this.style.display=\'none\'; ">(繼續閱讀)</a>'; } } } 可以改成: function init() { if( location.pathname.search(/^\/(index\.html)?$/) >= 0 ) { $$('stealth').each(function(element, index) { element.hide(); $$('.detect')[index].update('<a title="展開隱藏區塊" onClick=" $$(\'.stealth\')['+i+'].show(); $(this).hide(); ">(繼續閱讀)</a>'); } } } 反正... document.getElementByClassName('blah') -> $$('.blah') for 迴圈 ->.each() element.innerHTML = 'blah' -> element.update('blah') new Array(1, 2, 3) -> [1, 2, 3] Opera 的錯誤是 unknown thread? 喔喔 原來還有這招,受教了 之前雖然有去翻過API 不過好像都沒抓到要領 至於Opera的錯誤,是的 用Firefox也會有一些警告出現在prototype.js裡 有可能是我傳了不嚴謹的物件 但是我找不出來= = |
第 1 頁 (共 1 頁) | 所有顯示的時間為 UTC + 8 小時 |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |