I am currently working within the confines of sharepoint 2007 and have some code that turns a dropdownlist into a combobox. What i have works perfectly fine, however this code is meant to be used by business analysts and content creators so it has to be as simple as possible. So i am condensing it into a function and all has gone swimmingly except for the onChange event.
I have managed to extract the original onChange event, though due to my dropdownlist i have to replace a parameter. So i convert it to a string, replace the parameter and need to reconvert it to a function a la:
var onChangeFunction = "function (){alert("your function has been called")}"
//The function 'attachEvent' is not co开发者_如何学JAVAmmon javascript. It is a custom function
//that works for my combobox.
combobox.attachEvent("onChange",(function)onChangeFunction);
Is that even possible?
You can use new Function
but I think you are on a slippery slope playing with this.
var fn = new Function("{alert(\"your function has been called\")}")
combobox.attachEvent("onChange",fn);
精彩评论