JavaScript DHTML/YUI Library/YUI

Материал из Web эксперт
Версия от 10:28, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Adding new object members during parsing

   <source lang="html4strict">



<head>

   <meta http-equiv="content-type" content="text/html; charset=utf-8">

<title>Adding new object members during parsing</title> <style type="text/css"> /*margin and padding on body element

 can introduce errors in determining
 element position and are not recommended;
 we turn them off as a foundation for YUI
 CSS treatments. */

body {

 margin:0;
 padding:0;

} </style> <link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" /> <script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script> <script type="text/javascript" src="yui_2.7.0b-lib/connection/connection-min.js"></script> <script type="text/javascript" src="yui_2.7.0b-lib/json/json-min.js"></script>


<style type="text/css">

  1. demo table {
   border: 3px solid #89d;
   border-collapse: collapse;

}

  1. demo caption {
   margin: 3px 0;
   font-weight: bold;
   color: #333;
   margin: 1em 0 1ex;

}

  1. demo table th {
   background: #89d;
   color: #fff;
   padding: 1ex 1em;

}

  1. demo table td {
   background: #fff;
   border: 1px solid #ddd;
   padding: .5ex 1ex;

} </style>

</head> <body class=" yui-skin-sam">

Adding new object members during parsing

This example shows how to use the reviver parameter in JSON.parse to add new object members and format existing members during the parsing phase.

Choose a currency, then get the data

   <select id="currencies">
       <option value="ARS">Argentine Peso</option>
       <option value="AUD">Australian Dollar</option>
       <option value="BRL">Brazilian Real</option>
       <option value="GBP">British Pound</option>
       <option value="CAD">Canadian Dollar</option>
       <option value="CNY">Chinese Yuan</option>
       <option value="COP">Colombian Peso</option>
       <option value="HRK">Croatian Kuna</option>
       <option value="CZK">Czech Koruna</option>
       <option value="DKK">Danish Krone</option>
       <option value="EEK">Estonian Kroon</option>
       <option value="EUR">Euro</option>
       <option value="HKD">Hong Kong Dollar</option>
       <option value="HUF">Hungarian Forint</option>
       <option value="ISK">Iceland Krona</option>
       <option value="INR">Indian Rupee</option>
       <option value="JPY">Japanese Yen</option>
       <option value="KRW">Korean Won</option>
       <option value="LVL">Latvian Lat</option>
       <option value="LTL">Lithuanian Lita</option>
       <option value="MYR">Malaysian Ringgit</option>
       <option value="MXN">Mexican Peso</option>
       <option value="NZD">New Zealand Dollar</option>
       <option value="NOK">Norwegian Krone</option>
       <option value="PHP">Philippine Peso</option>
       <option value="PLN">Polish Zloty</option>
       <option value="RUB">Russian Rouble</option>
       <option value="SGD">Singapore Dollar</option>
       <option value="SKK">Slovak Koruna</option>
       <option value="ZAR">South African Rand</option>
       <option value="LKR">Sri Lanka Rupee</option>
       <option value="SEK">Swedish Krona</option>
       <option value="TRY">Turkey Lira</option>
       <option value="USD" selected="selected">U.S. Dollar</option>
       <option value="CHF">Swiss Franc</option>
       <option value="TWD">Taiwan Dollar</option>
       <option value="THB">Thai Baht</option>
   </select>
   <input type="button" id="demo_go" value="Get Data">
<thead> </thead> <tbody>
   </tbody>
Inventory
SKU Item Price (USD) Price (USD)
Click Get Data

<script type="text/javascript"> YAHOO.util.Event.onDOMReady(function () { // Set up some shortcuts var JSON = YAHOO.lang.JSON,

   Dom   = YAHOO.util.Dom,
   Event = YAHOO.util.Event,
   Demo;

Demo = YAHOO.namespace("demo").JSONReviver = {

   rates : {"USD":1,"EUR":0.6661,"GBP":0.5207,"AUD":1.1225,"BRL":1.609,"NZD":1.4198,"CAD":1.0667,"CHF":1.0792,"CNY":6.8587 ,"DKK":4.9702,"HKD":7.8064,"INR":42.0168,"JPY":109.8901,"KRW":1000,"LKR":107.5269,"MXN":10.1317,"MYR" :3.3167,"NOK":5.3277,"SEK":6.2617,"SGD":1.4073,"THB":33.7838,"TWD":31.1526,"VEF":2.1445,"ZAR":7.6923 ,"BGN":1.3028,"CZK":16.0514,"EEK":10.4275,"HUF":158.7302,"LTL":2.2999,"LVL":0.4692,"PLN":2.1758,"RON" :2.3804,"SKK":20.2429,"ISK":4.8008,"HRK":81.3008,"RUB":24.3309,"TRY":1.1811,"PHP":44.2478,"COP":2000 ,"ARS":3.1289},
   currency : "USD",
   formatCurrency : function (amt) {
       amt += amt % 1 ? "0" : ".00";
       return amt.substr(0,amt.indexOf(".")+3);
   },
   convert : function (k,v) {
       // "this" will refer to the object containing the key:value pair,
       // so this will add a new object member while leaving the original
       // in tact (but formatted to two decimal places).  If the original
       // is not needed, just return the converted value.
       if (k === "Price") {
           var x = Math.round(v * Demo.rates[Demo.currency] * 100) / 100;
           this.convertedPrice = Demo.formatCurrency(x); // added to item
           return Demo.formatCurrency(v); // assigned to item.Price
       }
       return v;
   },
   updateTable : function (inventory) {
       var demo       = Dom.get("demo"),
           tbl        = demo.getElementsByTagName("table")[0],
           tbody      = tbl.getElementsByTagName("tbody")[0],
           col_header = tbl.getElementsByTagName("span")[0],
           tmp        = document.createElement("div"),
html = ["<tbody>"],i,j = 1,l,item; // Update the column header col_header.innerHTML = Demo.currency; if (inventory) { for (i = 0, l = inventory.length; i < l; ++i) { item = inventory[i]; html[j++] = ""; } } else { html[j++] = "";
       }
html[j] = "</tbody>
";
               html[j++] = item.SKU;
html[j++] = "
";
               html[j++] = item.Item;
html[j++] = "
";
               html[j++] = item.Price;
html[j++] = "
";
               html[j++] = item.convertedPrice;
html[j++] = "
No Inventory data
";
       tmp.innerHTML = html.join("");
       tbl.replaceChild(tmp.getElementsByTagName("tbody")[0], tbody);
   }

}; Event.on("demo_go","click", function (e) {

   var self = this,     // Cache this for the async callback closure
       sel  = Dom.get("currencies"); // Store the requested currency
   // Disable the button temporarily
   this.disabled = true;
   // Store the requested currency
   Demo.currency = sel.value;
   YAHOO.util.Connect.asyncRequest("GET","yui_2.7.0b-assets/json-assets/data.php",{
       timeout : 3000,
       success : function (res) {
           var inventory;
           try {
               inventory = JSON.parse(res.responseText,Demo.convert);
               Demo.updateTable(inventory);
           }
           catch(e) {
               alert("Error getting inventory data");
           }
           finally {
               self.disabled = false;
           }
       },
       failure : function () {
           alert("Error getting inventory data");
       }
   });

}); }); </script> </script>

</body>


 </source>
   
  

<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>


Getting a Script File with YUI Get

   <source lang="html4strict">


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head>

   <meta http-equiv="content-type" content="text/html; charset=utf-8">

<title>Quickstart Example: Getting a Script File with YUI Get</title> <style type="text/css"> /*margin and padding on body element

 can introduce errors in determining
 element position and are not recommended;
 we turn them off as a foundation for YUI
 CSS treatments. */

body {

 margin:0;
 padding:0;

} </style> <link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" /> <link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/button/assets/skins/sam/button.css" /> <script type="text/javascript" src="yui_2.7.0b-lib/yuiloader-dom-event/yuiloader-dom-event.js"></script> <script type="text/javascript" src="yui_2.7.0b-lib/element/element-min.js"></script> <script type="text/javascript" src="yui_2.7.0b-lib/button/button-min.js"></script>


<style type="text/css">

 #returnedData {background-color:#0000ff; color:#ffffff; padding:1em; margin-top:1em; white-space:normal;}

</style>

</head> <body class=" yui-skin-sam">

Quickstart Example: Getting a Script File with YUI Get

This example explores the simplest and most common use case for the <a href="http://developer.yahoo.ru/yui/get">YUI Get Utility</a>: fetching a script with YAHOO.util.Get.script() and making use of its contents.

Click the button to retrieve the script and output its data to the blue box. The tutorial below gives you a full description of how to use this technique.

 <button id="getScript">Get Data from Script</button>
  Data returned from the loaded script will appear here after you click the button above.

<script language="JavaScript"> (function() {

 //We"ll use a YUI Button to actuate our request for the script:
 var button = new YAHOO.widget.Button("getScript", {type: "link"});
 
 //When the button is clicked, we"ll make the script request:
 button.on("click", function() {
   
   YAHOO.log("Button was clicked; loading script with Get Utility.", "info", "example");
   //We have a .js file at yui_2.7.0b-assets/get-assets/simple_get.js.  We will get
   //that script with the Get Utility:
   YAHOO.util.Get.script("yui_2.7.0b-assets/get-assets/simple_get.js", {
     
     //ALL OF THE CONFIGURATION OPTIONS BELOW ARE OPTIONAL;
     //IN MANY CASES, YOU"LL NEED ONLY TO DEFINE YOUR SUCCESS/
     //FAILURE HANDLERS.
     
     //callback to fire when the script is successfully loaded:
     onSuccess: function(obj) {
       YAHOO.log("Success handler was called. Transaction ID: " + obj.tId, "info", "example");
       document.getElementById("returnedData").innerHTML = YAHOO.lang.dump(YAHOO.simple_get.data, 3);
     },
     
     //callback to fire if the script does not successfully load:
     onFailure: function(o) {
       YAHOO.log("Failure handler was called. Transaction ID: " + obj.tId, "info", "example");
     },
     
     //context under which success and failure handlers should run;
     //default is the current window, which we"ll use for this example:
     scope: window,
     
     //by default, the script will be added to the current
     //window; use this property to override that default
     //(we"re just using the default in this example):
     win: window,
     
     //will be passed as a member of the callback object to
     //the success or failure handler:
     data: {testData: "value"},
     
     //For Safari 2.x, which does not support the script"s onload
     //event to determine when the script is loaded; instead, Get
     //will check for the presence of this varName (which is
     //defined in the script we"re retrieving) and use its presence
     //to determine when the script has been successfully loaded:
     varName: ["YAHOO.simple_get.data"]
   });
   
 });
 

})(); </script>

</body> </html>


 </source>
   
  

<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>


Looks at the "standard module format" used by many components in YUI to represent modular content on the page.

   <source lang="html4strict">


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head>

   <meta http-equiv="content-type" content="text/html; charset=utf-8">

<title>The Module Control</title> <style type="text/css"> /*margin and padding on body element

 can introduce errors in determining
 element position and are not recommended;
 we turn them off as a foundation for YUI
 CSS treatments. */

body {

 margin:0;
 padding:0;

} </style> <link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" /> <link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/container/assets/skins/sam/container.css" /> <script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script> <script type="text/javascript" src="yui_2.7.0b-lib/container/container-min.js"></script>

</head> <body class=" yui-skin-sam">

The Module Control

This example looks at the "standard module format" used by many components in YUI to represent modular content on the page. The Module Control is a JavaScript representation of a standard module, one that provides some basic plumbing for interacting with the head, body and foot sections of a standard module. Convenience methods for showing, hinding and rendering the module are also included in the Module Control.

You"re most likely to use the Module Control when building a custom widget; its importance in the YUI Library is as a foundation rather than as a UI control in its own right.

<style type="text/css">

 .yui-module { border:1px dotted black;padding:5px;margin:10px; display:none; }
 .yui-module .hd { border:1px solid red;padding:5px; }
 .yui-module .bd { border:1px solid green;padding:5px; }
 .yui-module .ft { border:1px solid blue;padding:5px; }

</style> <script type="text/javascript">

   YAHOO.namespace("example.container");
   YAHOO.util.Event.onDOMReady(function () {
       YAHOO.example.container.module1 = new YAHOO.widget.Module("module1", { visible: false });
       YAHOO.example.container.module1.render();
       YAHOO.example.container.module2 = new YAHOO.widget.Module("module2", { visible: false });
       YAHOO.example.container.module2.setHeader("Module #2 from Script");
       YAHOO.example.container.module2.setBody("This is a dynamically generated Module.");
       YAHOO.example.container.module2.setFooter("End of Module #2");
       YAHOO.example.container.module2.render();
       YAHOO.util.Event.addListener("show1", "click", YAHOO.example.container.module1.show, YAHOO.example.container.module1, true);
       YAHOO.util.Event.addListener("hide1", "click", YAHOO.example.container.module1.hide, YAHOO.example.container.module1, true);
       YAHOO.util.Event.addListener("show2", "click", YAHOO.example.container.module2.show, YAHOO.example.container.module2, true);
       YAHOO.util.Event.addListener("hide2", "click", YAHOO.example.container.module2.hide, YAHOO.example.container.module2, true);
   });

</script>

 <button id="show1">Show module1</button> 
 <button id="hide1">Hide module1</button>
Module #1 from Markup
This is a Module that was marked up in the document.
End of Module #1
 <button id="show2">Show module2</button> 
 <button id="hide2">Hide module2</button>

</body> </html>


 </source>
   
  

<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>


Retrieving a Yahoo! Weather RSS Feed

   <source lang="html4strict">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head>

   <meta http-equiv="content-type" content="text/html; charset=utf-8">

<title>Retrieving a Yahoo! Weather RSS Feed</title> <style type="text/css"> /*margin and padding on body element

 can introduce errors in determining
 element position and are not recommended;
 we turn them off as a foundation for YUI
 CSS treatments. */

body {

 margin:0;
 padding:0;

} </style> <link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" /> <script type="text/javascript" src="yui_2.7.0b-lib/yahoo/yahoo-min.js"></script> <script type="text/javascript" src="yui_2.7.0b-lib/event/event-min.js"></script> <script type="text/javascript" src="yui_2.7.0b-lib/connection/connection-min.js"></script>

</head> <body class=" yui-skin-sam">

Retrieving a Yahoo! Weather RSS Feed

This example demonstrates how to use the <a href="http://developer.yahoo.ru/yui/connection/">Connection Manager</a> and a PHP proxy — to work around XMLHttpRequest"s same-domain policy — to retrieve an XML document from http://xml.weather.yahoo.ru/forecastrss.

To try out the example, fill in your five-digit US zip code, or Location ID.

<form id="wForm"> <fieldset>

 <label>Zip Code or Location ID</label> <input type="text" name="zip" value="94089">

Please enter a U.S. Zip Code or a location ID to get the current temperature. The default is Zip Code 94089 for Sunnyvale, California; its location ID is: USCA1116.

</fieldset>

<input type="button" value="Get Weather RSS" onClick="getModule()"> </form> <script> var div = document.getElementById("weatherModule"); var oForm = document.getElementById("wForm"); function successHandler(o){

 YAHOO.log("Success handler called; handler will parse the retrieved XML and insert into DOM.", "info", "example");
 var root = o.responseXML.documentElement;
 var oTitle = root.getElementsByTagName("description")[0].firstChild.nodeValue;
 var oDateTime = root.getElementsByTagName("lastBuildDate")[0].firstChild.nodeValue;
 var descriptionNode = root.getElementsByTagName("description")[1].firstChild.nodeValue;
div.innerHTML = "

" + oTitle + "

" + "

" + oDateTime + "

" + descriptionNode;
 YAHOO.log("Success handler is complete.", "info", "example");

} function failureHandler(o){

 YAHOO.log("Failure handler called; http status: " + o.status, "info", "example");
 div.innerHTML = o.status + " " + o.statusText;

} function getModule(){

 var iZip = oForm.elements["zip"].value;
 var entryPoint = "yui_2.7.0b-assets/connection-assets/weather.php";
 var queryString = encodeURI("?p=" + iZip);
 var sUrl = entryPoint + queryString;
 YAHOO.log("Submitting request; zip code: " + iZip, "info", "example");
 var request = YAHOO.util.Connect.asyncRequest("GET", sUrl, { success:successHandler, failure:failureHandler });

} YAHOO.log("When you retrieve weather RSS data, relevant steps in the process will be reported here in the logger.", "info", "example"); </script>

</body> </html>


 </source>
   
  

<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>


Type-Checking Your Data

   <source lang="html4strict">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head>

   <meta http-equiv="content-type" content="text/html; charset=utf-8">

<title>Type-Checking Your Data</title> <style type="text/css"> /*margin and padding on body element

 can introduce errors in determining
 element position and are not recommended;
 we turn them off as a foundation for YUI
 CSS treatments. */

body {

 margin:0;
 padding:0;

} </style> <link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" /> <script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script>


<style type="text/css">

   #demo {
       border-collapse: collapse;
   }
   #demo th {
       background: #E76300;
       color: #fff;
       padding: .2em 1em;
       border: 1px solid #ccc;
   }
   #demo td {
       padding: .2em 1ex;
       border: 1px solid #ccc;
       text-align: center;
   }
   #demo code {
       background: #eee;
       display: block;
       text-align: left;
   }

</style>

</head> <body class=" yui-skin-sam">

Type-Checking Your Data

The <a href="http://developer.yahoo.ru/yui/yahoo/">Yahoo Global Object</a> includes several useful type-checking methods in the YAHOO.lang object. Click the Check button in each row to evaluate the data.

<thead> </thead> <tbody> <tbody>
Data isObject isArray isFunction
null<code></td> <input type="button" name="demo-1" id="demo-1" value="check"/></td>
       </tr>
<code>[] or new Array() <input type="button" name="demo-2" id="demo-2" value="check"/>
{} or new Object() <input type="button" name="demo-3" id="demo-3" value="check"/>
function Foo() {} <input type="button" name="demo-4" id="demo-4" value="check"/>
new Foo() <input type="button" name="demo-5" id="demo-5" value="check"/>
elem.getElementsByTagName("p") <input type="button" name="demo-6" id="demo-6" value="check"/>
YAHOO.util.Dom.
                       getElementsByClassName(
"foo","p",elem)
<input type="button" name="demo-7" id="demo-7" value="check"/>

<script type="text/javascript">

   YAHOO.namespace("example");
   YAHOO.example.checkType = function (val) {
       return {
           "object"  : YAHOO.lang.isObject(val),
           "array"   : YAHOO.lang.isArray(val),
           "function": YAHOO.lang.isFunction(val)
       };
   }
   YAHOO.example.populateRow = function (e, data) {
       var cell = this.parentNode,
           row  = cell.parentNode;
       row.removeChild(cell);
       var td0 = document.createElement("td"),
           td1 = td0.cloneNode(false),
           td2 = td0.cloneNode(false);
       var results = YAHOO.example.checkType(data);
       td0.appendChild(document.createTextNode(
           results["object"] ?   "Y" : "N"));
       td1.appendChild(document.createTextNode(
           results["array"] ?    "Y" : "N"));
       td2.appendChild(document.createTextNode(
           results["function"] ? "Y" : "N"));
       row.appendChild(td0);
       row.appendChild(td1);
       row.appendChild(td2);
   }
   var foo = function () {};
   var f = document.getElementById("demo");
   YAHOO.util.Event.on("demo-1","click",YAHOO.example.populateRow, null);
   YAHOO.util.Event.on("demo-2","click",YAHOO.example.populateRow, []);
   YAHOO.util.Event.on("demo-3","click",YAHOO.example.populateRow, {});
   YAHOO.util.Event.on("demo-4","click",YAHOO.example.populateRow, foo);
   YAHOO.util.Event.on("demo-5","click",YAHOO.example.populateRow, new foo());
   YAHOO.util.Event.on("demo-6","click",YAHOO.example.populateRow,
       f.getElementsByTagName("tr"));
   YAHOO.util.Event.on("demo-7","click",YAHOO.example.populateRow,
       YAHOO.util.Dom.getElementsByClassName("foo","td",f));

</script>

</body> </html>


 </source>
   
  

<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>


Use YAHOO.env.ua to identify the user"s browser and to branch JavaScript logic based on what browser is being used.

   <source lang="html4strict">


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head>

   <meta http-equiv="content-type" content="text/html; charset=utf-8">

<title>User Agent Detection</title> <style type="text/css"> /*margin and padding on body element

 can introduce errors in determining
 element position and are not recommended;
 we turn them off as a foundation for YUI
 CSS treatments. */

body {

 margin:0;
 padding:0;

} </style> <link rel="stylesheet" type="text/css" href="yui_2.7.0b-lib/fonts/fonts-min.css" /> <script type="text/javascript" src="yui_2.7.0b-lib/yahoo-dom-event/yahoo-dom-event.js"></script> <script type="text/javascript" src="yui_2.7.0b-lib/dragdrop/dragdrop-min.js"></script>


<style type="text/css">

   #dd1,#dd2 {
       position: relative;
       margin: 1em 1em 0;
       width: 175px;
       float: left;
       cursor: move;
   }
   #demo p {
       position: relative;
       padding: 1em;
       height: 100%;
       margin: 0;
       font-weight: bold;
       text-align: center;
       z-index: 20;
   }
   #dd1 p {
       border: 10px solid #ccc;
       background-color: #eee;
   }
   #dd2 p {
       border: 10px solid #e76300;
       background-color: #fff5df;
   }
   #demo .shim {
       position: absolute;
       top: 0;
       left: 0;
       width: 100%;
       margin: 0;
       padding: 0;
       border: 0;
       z-index: 10;
   }

</style>

</head> <body class=" yui-skin-sam">

User Agent Detection

This example demonstrates the use of YAHOO.env.ua to identify the user"s browser and to branch JavaScript logic based on what browser is being used. (Note: We strongly recommend using feature detection rather than user-agent sniffing to fork code; only use this technique where it is absolutely necessary to do so — for example, in cases where browsers do not report their own capabilities accurately.)

   <select name="foo">
       <option value="NONE" selected="selected">This is a very long select element for the example</option>
       <option value="1">Apple</option>
       <option value="2">Rutabaga</option>
       <option value="3">Motor oil</option>
   </select>

NO IFRAME
Drag over the select

IFRAME
Drag over the select

<script type="text/javascript"> YAHOO.util.Event.onDOMReady(function () {

   var dd1 = new YAHOO.util.DD("dd1");
   var dd2 = new YAHOO.util.DD("dd2");
   dd1.startDrag = function (x,y) {
       YAHOO.log("Drag started for element with no protection from the display bug", "info", "example");
   }
   if (YAHOO.env.ua.ie > 5 && YAHOO.env.ua.ie < 7) {
       // Create an iframe shim
       var shim = document.createElement("iframe");
       shim.src = "about:blank";
       shim.className = "shim";
       // Add the shim to the dragging element on the first startDrag
       dd2.startDrag = function (x,y) {
           var d = this.getEl();
           if (d.firstChild !== shim) {
               YAHOO.util.Dom.setStyle(shim, "height",d.offsetHeight);
               d.insertBefore(shim, d.firstChild);
               YAHOO.log("Your browser is IE " + YAHOO.env.ua.ie + ".  Shim added.", "info","example");
           } else {
               YAHOO.log("Your browser is IE " + YAHOO.env.ua.ie + ", but the shim was already added", "info","example");
           }
       }
   } else { // Not shim worthy
       dd2.startDrag = function (x,y) {
           YAHOO.log("Your browser is NOT IE.  No shim added.", "info", "example");
       }
   }

}); </script>

</body> </html>


 </source>
   
  

<A href="http://www.wbex.ru/Code/JavaScriptDownload/yui_2.7.0b.zip">yui_2.7.0b.zip( 4,431 k)</a>