HighDots Forums  

INFO SU OPERA

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss INFO SU OPERA in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
tomomot
 
Posts: n/a

Default INFO SU OPERA - 10-24-2003 , 01:02 PM






Xkè questo script che mi dice il nome del browser con opera mi dice che sto
usando IE6?

<SCRIPT>
<!--
document.write(navigator.appVersion)
//-->
</SCRIPT>


Ce ne sono altre versioni, magari compatibile con tutti i browser?



Reply With Quote
  #2  
Old   
paolibo
 
Posts: n/a

Default Re: INFO SU OPERA - 10-24-2003 , 01:35 PM






Quote:
Xkè questo script che mi dice il nome del browser con opera mi dice che
sto
usando IE6?

SCRIPT
!--
document.write(navigator.appVersion)
//--
/SCRIPT

Effettivamente Opera viene interpretato come se fosse Explorer.
Per"separarlo" da IE ed intercettarlo in modo univoco puoi aggiungere una
variabile ed un costrutto "else if". Detto ciò prova così:

<SCRIPT language="JavaScript">
<!--
var OPER=navigator.userAgent.indexOf("Opera");
if (document.layers){ //Netscape 4.x
document.write("Io sono Netscape 4.x");
}
else if((OPER>-1)) {
document.write("Io sono Opera");
}
else if (document.all){ // Explorer
document.write("Io sono Explorer");
}
else if (document.getElementById){ //Netscape 6
document.write("Io sono Netscape 6");
}
//-->
</SCRIPT>

Quindi per evitare che Opera venga intercettato come se fosse Explorer, è
necessario utilizzare le istruzioni "else if" e rispettare l'ordine dei
costrutti.
ciauz




Reply With Quote
  #3  
Old   
tomomot
 
Posts: n/a

Default Re: INFO SU OPERA - 10-24-2003 , 02:00 PM



Ok, ho risolto mettendo navigator.userAgent



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.