YAHOO.util.Dom.setXY('MyID', new Array(10,10));
Although YUI gets the job done, the syntax is thoroughly verbose. YAHOO.util.Dom.setStyle('MyDivID', 'opacity', .5);
The caveat of so many of these wonderful capabilities is again the documentation. The documentation implies that you can set the CSS style properties on all elements using their Javascript equivalent names, for example, by writing backgroundColor rather than the CSS equivalent background-color, but the downside is that it lacks a full list of supported properties. var handlers = {
success: success,
failure: failure }
function success(t)
{ alert('Yea, success'); }
function failure(t)
{ alert('Awww.'); }
YAHOO.util.Connect.asyncRequest('GET',
'http://mysite.com/Remote.aspx?GetPage=1',
handlers,null);
Despite the fact that the connection library is one of the strong points of YUI, I would still recommend sticking with whatever AJAX libraries are specifically designed for your server-side language. The reason for this is simple—consistency in data type handling will reduce the overall amount of effort required to achieve the desired result. However, if you work in a multi-language or multi-platform environment, the YUI connection library is the better choice.新闻热点
疑难解答