开发者

Why does this Javascript act differently, in the same browser, based on where it is ran?

I have a YUI application and in this particular instance I'm merely trying to set an attribute on an input element using the following code.

var itemDescription = document.createElement( "input" );
itemDescription.setAttribute("type","text");
YAHOO.util.Dom.addClass( itemDescription, "textInput" );
YAHOO.util.Dom.addClass( itemDescription, (isPicture ? "pictureTextInput" : "otherTextInput" ) );
YAHOO.util.Dom.setAttribute( itemDescription, "maxlength", (isPicture ? "60" : "40" ) );
itemDescription.maxlength = (isPicture ? "60" : "40" );
itemDescription.name = "description";
itemDescription.title = "description";
itemDescription.id = "desc-"+this.fileId;

Of particular interest is line 5 (and, perhaps, line 6) where the maxLength attribute is set. When I open this site from a local Tomcat 6 server running Windows XP the attribute is set correctly. Debugging through it with IE8's developer tools shows that both innerHtml and maxLength are set to the correct value. When I open this site on our remote AIX server running Web开发者_如何学编程logic 10 only innerHtml is being set, leaving the actual maxLength attribute unchanged.

I know that the code doesn't (properly?) reference the case-sensitive name of the attribute, but I still don't understand why the expected behavior is achieved locally and not remotely. I can't for the life of me think of why the OS or Servlet container should matter, but I'm barely competent in Javascript and inherited this codebase, so, for clarity's sake, here are the environment stats.

Local OS: Windows XP Servlet Container: Tomcat 6

Remote OS: AIX Servlet Container: Weblogic 10

The browser I'm using is IE8 (8.0.6001.18702).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜