Jump to content

Comentarii Conditionale - Pentru Un Anumit Browser


Recommended Posts

Posted

Comentariile conditionale sunt folosite pentru a detecta o conditie o regula sau o cerinta pentru un anumit browser sau o anumita versiune de browser din conditia exprimata. In general comentariile conditionale sunt folosite pentru Internet Explorer. Exista 2 tipuri de comentarii conditionale: ascunse(ascund HTML-ul de non-IE browsere) sau vizibile.

O sintaxa de baza are:

<!--[if condition]>
(introduceti HTML pentru folosire daca conditia este adevarata)
<![endif]-->[/code]

Pentru diferite vesiuni de IE sintaxa comentariilor conditionale arata:

[html]<!--[if IE]>
<p>Acest mesaj apare doar in IE.</p>
<![endif]-->

<!--[if IE 5]>
<p>Acest mesaj apare doar in IE5.</p>
<![endif]-->

<!--[if IE 5.0]>
<p>Acest mesaj apare doar in IE5.0</p>
<![endif]-->

<!--[if IE 5.5]>
<p>Acest mesaj apare doar in IE5.5</p>
<![endif]-->

<!--[if IE 6]>
<p>Acest mesaj apare doar in IE6.</p>
<![endif]-->

<!--[if IE 7]>
<p>Acest mesaj apare doar in IE7.</p>
<![endif]-->

<!--[if gte IE 5]>
<p>Acest mesaj apare in IE5 si versiuni mai noi(cum ar fi IE6).</p>
<![endif]-->

<!--[if lt IE 6]>
<p>Acest mesaj apare doar in versiuni mai vechi de IE6(cum ar fi IE5).</p>
<![endif]-->

<!--[if lte IE 5.5]>
<p>Acest mesaj apare doar in IE5.5 sau versiuni mai vechi(cum ar fi IE5).</p>
<![endif]-->

<!--[if gt IE 6]>
<p>Acest mesaj apare doar in versiuni mai noi de IE6(cum ar fi IE7).</p>
<![endif]-->[/html]

[color=red][b]*[/b][/color][b]Unde IE inseamna [color=green]Internet Explorer[/color][/b] !!!

  • [b][color=orange]gt[/color] = greater than (mai mare ca)[/b]
  • [b][color=blue]lte[/color] = less than or equal to (mai mic ca sau egal cu)[/b]

Uitati si un exemplu de cum arata un comentariu conditional atunci cand dorim sa introducem un fisier CSS care sa fie aplicabil pentru o anumita vesiune de IE:

[html]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css"/>

<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="ie6.css"/>
<![endif]-->

</head>
<body>
<div id="continut">
<p>Model de comentariu conditional. Pentru orice versiune mai mica de IE 7.</p>
<p>In ie6.css se vor introduce linile pentru a evita bugurile.</p>
</div>
</body>
</html>[/html]

Te-ai inregistrat? Ne-ar placea sa te prezinti.

Cum pot sustine forumul?
Cumpara de la eMag folosind acest link.
--------------------
oG2BN9d.gifse1WdXd.gifQG6MtmI.gifRHYjDzD.gifG5p1wui.gif

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.