سؤال

Am using Salesforce and I need to use stuff like onfocus="js_fn1(this,'param1'..) etc.

For a peculiar requirement, am trying to pass an anonymous function as a parameter to a function I am binding onfocus. Here's the generated HTML:

<input onfocus="self=this;new AutoComplete('thePage:j_id3:thePageBlockId:j_id45:j_id46:pName','thePage:j_id3:thePageBlockId:j_id45:j_id46:primaryNameSuggestWrap', searchNamesfn, function(){fireAddressSearch(self, 'thePage:j_id3:thePageBlockId:j_id45:j_id46:address', 'thePage:j_id3:thePageBlockId:j_id45:j_id46:addressSuggestWrap', searchAddressesfn, selectAddressesfn);});return false;" onkeypress="return noenter(event)" id="thePage:j_id3:thePageBlockId:j_id45:j_id46:pName" type="text" name="thePage:j_id3:thePageBlockId:j_id45:j_id46:pName" value="" class="cField" />

This works beautifully in Chrome 10 and Firefox 3.6. But it seems to fail in, you guessed it, IE8. I've had a few pokes around this but couldn't conclude anything else - that IE doesn't support anon functions in obtrusive js? IE8 said

Message: Not implemented

Line: 219
Char: 1
Code: 0

At line 219 I have the input field Can someone tell me how I can fix this?

هل كانت مفيدة؟

المحلول

Thanks to meouw for the useful comment.

Answer: It seems 'self' is reserved in IE

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top