Friday, May 7, 2010

getAttribute("href",MAGIC_FLAG)

I have notice the cross-browser difference on
getAttribute("href"), value.href
long, long time ago,
but I hade no reasonable explanation nor workaround ;-(

Of course jQuery people already knew ;-)
// Check to see if an attribute returns normalized href attributes
div.innerHTML = "";
if (div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
div.firstChild.getAttribute("href") !== "#") {
Expr.attrHandle.href = function(elem) {
return elem.getAttribute("href", 2);
};
}
I have missed the RTFM step ?

http://msdn.microsoft.com/en-us/library/ms536429(VS.85).aspx

Thursday, May 6, 2010

Safari crops all (maxLength=5 and 123456)

http://www.w3.org/TR/html401/interact/forms.html#adef-maxlength
this attribute specifies the maximum number of characters the user may enter.
All tested browsers (MSIE, FF, Opera, Chrome, Safari) follow this line. However all except safari are too precise and allow user to enter 5 chars maximum, but server markup and client code can fill whatever value. Safari forces all (server markup, client script and user) to obey 5, too long string "123456" received from server markup input type text="123456" set by client code i.value="123456"; i.setAttribute("value","123456") or typed by user will always end up CROPPED as 12345. All others will show overflowed "123456" (even Chrome ;-)).

ViewLocationFormats (just code hint)

To use standard engine but searching in modified (extended) list of locations: protected void Application_Start() { ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new WebFormViewEngine() { ViewLocationFormats = new[] { "~/MYEXTRALOCATION/Views/{1}/{0}/Form.aspx", "~/Views/{1}/{0}.aspx", "~/Views/{1}/{0}.ascx", "~/Views/Shared/{0}.aspx", "~/Views/Shared/{0}.ascx" }, }); RegisterRoutes(RouteTable.Routes); }