<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Problema in IE risolto]]></title><description><![CDATA[<p dir="auto">Premetto che in Firefox e in Opera si vedeva bene a qualsiasi risoluzione.<br />
Ma in IE c'erano dei problemi.</p>
<p dir="auto">I problemi riguardano un layout table-less (xhtml + css) a tre colonne dotato di header e footer (anche se non è di questi di cui ci dobbiamo preoccupare).<br />
Potete vedere qui il risultato: <a href="http://www.keratox.net" rel="nofollow ugc">http://www.keratox.net</a> .</p>
<p dir="auto">Gli errori interessavano la larghezza (width) della colonna centrale.</p>
<p dir="auto">Poichè le colonne laterali occupavano un buon 20% a testa della pagina, rimaneva centralmente circa 60% di spazio.<br />
Firefox e opera, browser seri, per far si' che la colonna centrale prendesse tutto lo spazio, necessitavano di un width pari al 60% o con il valore 'auto'.<br />
In IE, invece, per una corretta visualizzazione, era necessario settare il width a 100%.</p>
<p dir="auto">Con i CSS era un bel guaio, perche', a meno di cambiare stile progettuale del layout (magari usando i posizionamenti assoluti invece dei float), non vedevo tante vie di salvezza.</p>
<p dir="auto">Così si è accesa la lampadina: javascript.</p>
<p dir="auto">Riconoscendo il browser, potevo cambiare lo stile del div#center (la colonna centrale).</p>
<pre><code>&lt;script type="text/javascript"&gt;
function forIE&amp;#40;&amp;#41;&amp;#123;
if&amp;#40;navigator.appName=="Microsoft Internet Explorer"&amp;#41;&amp;#123;
  document.all.center.style.width='100%';
&amp;#125;
&amp;#125;
&lt;/script&gt;
....
&lt;body onload="forIE&amp;#40;&amp;#41;;"&gt;
....
</code></pre>
<p dir="auto">Il primo script (utilizzando navigator.appName) sembrava andar bene, ma, oh! Vado a vedere con Opera, e si vede male (perche' associa il 100% che dovrebbe essere associato solo in IE).</p>
<p dir="auto">Ecco la spiegazione (tratta da <a href="http://www.quirksmode.org/js/detect.html" rel="nofollow ugc">http://www.quirksmode.org/js/detect.html</a>)</p>
<blockquote>
<p dir="auto">Never use navigator.appName. To hide their true identity, many browsers give this property the values Netscape or MSIE. Any browser detect based on navigator.appName is totally wrong.</p>
</blockquote>
<p dir="auto">Cosi' ho copiato il codice (sempre di quel sito)</p>
<pre><code>var detect = navigator.userAgent.toLowerCase&amp;#40;&amp;#41;;
var OS,browser,version,total,thestring;

if &amp;#40;checkIt&amp;#40;'konqueror'&amp;#41;&amp;#41;
&amp;#123;
	browser = "Konqueror";
	OS = "Linux";
&amp;#125;
else if &amp;#40;checkIt&amp;#40;'safari'&amp;#41;&amp;#41; browser = "Safari"
else if &amp;#40;checkIt&amp;#40;'omniweb'&amp;#41;&amp;#41; browser = "OmniWeb"
else if &amp;#40;checkIt&amp;#40;'opera'&amp;#41;&amp;#41; browser = "Opera"
else if &amp;#40;checkIt&amp;#40;'webtv'&amp;#41;&amp;#41; browser = "WebTV";
else if &amp;#40;checkIt&amp;#40;'icab'&amp;#41;&amp;#41; browser = "iCab"
else if &amp;#40;checkIt&amp;#40;'msie'&amp;#41;&amp;#41; browser = "Internet Explorer"
else if &amp;#40;!checkIt&amp;#40;'compatible'&amp;#41;&amp;#41;
&amp;#123;
	browser = "Netscape Navigator"
	version = detect.charAt&amp;#40;8&amp;#41;;
&amp;#125;
else browser = "An unknown browser";

if &amp;#40;!version&amp;#41; version = detect.charAt&amp;#40;place + thestring.length&amp;#41;;

if &amp;#40;!OS&amp;#41;
&amp;#123;
	if &amp;#40;checkIt&amp;#40;'linux'&amp;#41;&amp;#41; OS = "Linux";
	else if &amp;#40;checkIt&amp;#40;'x11'&amp;#41;&amp;#41; OS = "Unix";
	else if &amp;#40;checkIt&amp;#40;'mac'&amp;#41;&amp;#41; OS = "Mac"
	else if &amp;#40;checkIt&amp;#40;'win'&amp;#41;&amp;#41; OS = "Windows"
	else OS = "an unknown operating system";
&amp;#125;

function checkIt&amp;#40;string&amp;#41;
&amp;#123;
	place = detect.indexOf&amp;#40;string&amp;#41; + 1;
	thestring = string;
	return place;
&amp;#125;
</code></pre>
<p dir="auto">L'ho modificato secondo le mie necessità (levando OS, versione ...).<br />
Cosi</p>
<pre><code>&lt;script type="text/javascript"&gt;
&lt;!--
var detect = navigator.userAgent.toLowerCase&amp;#40;&amp;#41;;
var browser,version,total,thestring;

if &amp;#40;checkIt&amp;#40;'konqueror'&amp;#41;&amp;#41;
&amp;#123;
	browser = "Konqueror";
&amp;#125;
else if &amp;#40;checkIt&amp;#40;'safari'&amp;#41;&amp;#41; browser = "Safari"
else if &amp;#40;checkIt&amp;#40;'omniweb'&amp;#41;&amp;#41; browser = "OmniWeb"
else if &amp;#40;checkIt&amp;#40;'opera'&amp;#41;&amp;#41; browser = "Opera"
else if &amp;#40;checkIt&amp;#40;'webtv'&amp;#41;&amp;#41; browser = "WebTV";
else if &amp;#40;checkIt&amp;#40;'icab'&amp;#41;&amp;#41; browser = "iCab"
else if &amp;#40;checkIt&amp;#40;'msie'&amp;#41;&amp;#41; browser = "Internet Explorer"
else if &amp;#40;!checkIt&amp;#40;'compatible'&amp;#41;&amp;#41;
&amp;#123;
	browser = "Netscape Navigator"
&amp;#125;
else browser = "An unknown browser";


function checkIt&amp;#40;string&amp;#41;
&amp;#123;
	place = detect.indexOf&amp;#40;string&amp;#41; + 1;
	thestring = string;
	return place;
&amp;#125;

function check&amp;#40;&amp;#41;&amp;#123;
if&amp;#40;browser=="Internet Explorer"&amp;#41;
  document.all.center.style.width='100%';
&amp;#125;
//--&gt;
&lt;/script&gt;

....
&lt;body onload="check"&gt;
....
</code></pre>
<p dir="auto">E ora va bene ovunque.</p>
<p dir="auto">Finalmente.</p>
<p dir="auto">Andavo avanti nel sito anche senza correggere questo bug, aspettando risposte dai forum (il consiglio di javascript è venuto da un forum inglese).</p>
<p dir="auto">Ciao</p>
]]></description><link>https://dev.connect.gt/topic/1834/problema-in-ie-risolto</link><generator>RSS for Node</generator><lastBuildDate>Fri, 27 Nov 2026 05:40:56 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/1834.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 22 Jun 2005 09:45:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problema in IE risolto on Wed, 22 Jun 2005 10:14:41 GMT]]></title><description><![CDATA[<p dir="auto">di nulla  <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<p dir="auto">ciauz</p>
]]></description><link>https://dev.connect.gt/post/260687</link><guid isPermaLink="true">https://dev.connect.gt/post/260687</guid><dc:creator><![CDATA[keratox]]></dc:creator><pubDate>Wed, 22 Jun 2005 10:14:41 GMT</pubDate></item><item><title><![CDATA[Reply to Problema in IE risolto on Wed, 22 Jun 2005 09:57:53 GMT]]></title><description><![CDATA[<p dir="auto">keratox grazie molte <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://dev.connect.gt/post/260682</link><guid isPermaLink="true">https://dev.connect.gt/post/260682</guid><dc:creator><![CDATA[giorgiotave]]></dc:creator><pubDate>Wed, 22 Jun 2005 09:57:53 GMT</pubDate></item></channel></rss>