russe_91 | Bonjour,
Je suis en train de créer un site sous osdate et j'ai trouvé un mod permettant d'ajouter une zone avec des smileys juste en dessous de la zone du texte des messages. Le problème c'est que tout passse bien sous IE :
Et rien ne se passe sous Firefox quand je clic sur un smiley :
Voici le morceau de code du fichier .tpl qui contient les smileys :
Code :
- <tr><td></td>
- <td>
- <img src="/images/sml/aa.gif" border="0" onClick="smile('O:-)');" alt="O:-)">
- <img src="/images/sml/ab.gif" border="0" onClick="smile(':-)');" alt=":-)">
- <img src="/images/sml/ac.gif" border="0" onClick="smile(':-(');" alt=":-(">
- <img src="/images/sml/ad.gif" border="0" onClick="smile(';-)');" alt=";-)">
- <img src="/images/sml/ae.gif" border="0" onClick="smile(':-P');" alt=":-P">
- <img src="/images/sml/af.gif" border="0" onClick="smile(':8-)');" alt="8-)">
- <img src="/images/sml/ag.gif" border="0" onClick="smile(':-D');" alt=":-D">
- <img src="/images/sml/ah.gif" border="0" onClick="smile(':-[');" alt=":-[">
- <img src="/images/sml/ai.gif" border="0" onClick="smile('=-O');" alt="=-O">
- <img src="/images/sml/aj.gif" border="0" onClick="smile(':-*');" alt=":-*">
- <img src="/images/sml/ak.gif" border="0" onClick="smile(':k(');" alt=":k(">
- <img src="/images/sml/al.gif" border="0" onClick="smile(':-X');" alt=":-X">
- <img src="/images/sml/am.gif" border="0" onClick="smile('>:o');" alt=">:o">
- <img src="/images/sml/an.gif" border="0" onClick="smile(':-|');" alt=":-|">
- <img src="/images/sml/ao.gif" border="0" onClick="smile(':-x');" alt=":-x">
- </tr><tr><td></td>
- <td>
- <img src="/images/sml/ap.gif" border="0" onClick="smile('*JOKINGLY*');" alt="*JOKINGLY*">
- <img src="/images/sml/aq.gif" border="0" onClick="smile(']:->');" alt="]:->">
- <img src="/images/sml/ar.gif" border="0" onClick="smile('[:-}');" alt="[:-}">
- <img src="/images/sml/as.gif" border="0" onClick="smile('*KISSED*');" alt="*KISSED*">
- <img src="/images/sml/at.gif" border="0" onClick="smile(':-!');" alt=":-!">
- <img src="/images/sml/au.gif" border="0" onClick="smile('*STOP*');" alt="*STOP*">
- <img src="/images/sml/av.gif" border="0" onClick="smile('*KISSING*');" alt="*KISSING*">
- <img src="/images/sml/aw.gif" border="0" onClick="smile('@}->--');" alt="@}->--">
- <img src="/images/sml/ax.gif" border="0" onClick="smile('*THUMBS UP*');" alt="*THUMBS UP*">
- <img src="/images/sml/ay.gif" border="0" onClick="smile('*DRINK*');" alt="*DRINK*">
- <img src="/images/sml/ba.gif" border="0" onClick="smile('*IN LOVE*');" alt="*IN LOVE*">
- <img src="/images/sml/bb.gif" border="0" onClick="smile('@=');" alt="@=">
- <img src="/images/sml/bc.gif" border="0" onClick="smile('*HELP*');" alt="*HELP*">
- </tr><tr><td></td>
- <td>
- <img src="/images/sml/bd.gif" border="0" onClick="smile('/m');" alt="/m">
- <img src="/images/sml/be.gif" border="0" onClick="smile('%)');" alt="%)">
- <img src="/images/sml/bf.gif" border="0" onClick="smile('*OK*');" alt="*OK*">
- <img src="/images/sml/bh.gif" border="0" onClick="smile('*SORRY*');" alt="*SORRY*">
- <img src="/images/sml/bi.gif" border="0" onClick="smile('*BRAVO*');" alt="*BRAVO*">
- <img src="/images/sml/bj.gif" border="0" onClick="smile('*ROFL*');" alt="*ROFL*">
- <img src="/images/sml/bk.gif" border="0" onClick="smile('*PARDON*');" alt="*PARDON*">
- <img src="/images/sml/bl.gif" border="0" onClick="smile('*NO*');" alt="*NO*">
- <img src="/images/sml/bm.gif" border="0" onClick="smile('*CRAZY*');" alt="*CRAZY*">
- <img src="/images/sml/bn.gif" border="0" onClick="smile('*DONT_KNOW*');" alt="*DONT_KNOW*">
- <img src="/images/sml/bo.gif" border="0" onClick="smile('*DANCE*');" alt="*DANCE*">
- <img src="/images/sml/bp.gif" border="0" onClick="smile('*YAHOO*');" alt="*YAHOO*">
- </td>
- </tr>
|
Puis le fichier .js :
Code :
- var myAgent = navigator.userAgent.toLowerCase();
- var myVersion = parseInt(navigator.appVersion);
- var is_ie = ((myAgent.indexOf("msie" ) != -1) && (myAgent.indexOf("opera" ) == -1));
- var is_nav = ((myAgent.indexOf('mozilla')!=-1) && (myAgent.indexOf('spoofer')==-1)
- && (myAgent.indexOf('compatible') == -1) && (myAgent.indexOf('opera')==-1)
- && (myAgent.indexOf('webtv') ==-1) && (myAgent.indexOf('hotjava')==-1));
- var is_win = ((myAgent.indexOf("win" )!=-1) || (myAgent.indexOf("16bit" )!=-1));
- var is_mac = (myAgent.indexOf("mac" )!=-1);
- function smile( txt ) {
- // document.all.txtmessage.value = document.all.txtmessage.value + txt;
- // return false;
- doInsert(" " + txt + " ", "", false,document.all.txtmessage);
- }
- function smile2( txt ) {
- doInsert(" " + txt + " ", "", false,document.all.txttemplate);
- }
- function doInsert(ibTag, ibClsTag, isSingle, name_txt)
- {
- var isClose = false;
- var obj_ta = name_txt;
- if ( (myVersion >= 4) && is_ie && is_win)
- {
- // this doesn't work for NS, but it works for IE 4+ and compatible browsers
- if (obj_ta.isTextEdit)
- {
- obj_ta.focus();
- var sel = document.selection;
- var rng = sel.createRange();
- rng.colapse;
- if ((sel.type == "Text" || sel.type == "None" ) && rng != null)
- {
- if (ibClsTag != "" && rng.text.length > 0)
- ibTag += rng.text + ibClsTag;
- else if(isSingle)
- isClose = true;
- rng.text = ibTag;
- }
- }
- else
- {
- if (isSingle)
- isClose = true;
- obj_ta.value += ibTag;
- }
- }
- else
- {
- if (isSingle)
- isClose = true;
- obj_ta.value += ibTag;
- }
- obj_ta.focus();
- return isClose;
- }
- function CDE(elemId) {
- if(document.getElementById(elemId).style.display != "none" )
- document.getElementById(elemId).style.display = "none"
- else
- document.getElementById(elemId).style.display = "inline"
- }
|
Je viens de m'appercevoir que c'est même noté : pas compatible NS... Y aurait-il moyen de le rendre compatible ?
Merci ---------------
. FeedBack .
|