ChemAxon fa971619eb
06-10-2004 09:05:09
One nice HTML trick is to change the molecule that is displayed in a MViewPane as a result of a onmouseover event. This, for instance lets you get a preview of the molecule that a hyperlink will take you to. We're using this in our chemical registration system (http://www.managedventures.com/), but getting this to work needed a little trick for it to work reliably.
The problem is that the simplistic approach of just stuffing the molecule into the MViewPane as a result of the onmouseover event caused problems when running in Internet Explorer when the mouse is moved rapidly over the hyperlinks. This problem was not seen with Mozilla. It is caused by the setM() method of the MViewPane being called before the previous setM() method had completed. Presumably the setM() method is not thread safe, and Internet Explorer does not handle this nicely, and either pops up error alerts, or worse still, freezes completely.
The trick is to check whether a molecule is already being set, and if so to defer the operation. After trying various ways of doing this the ChemAxon guys pointed out a neat parameter for MViewPane that helps here, the molChanged# param where # is the index of the mol in the MViewPane grid (e.g. 0, 1, 2...). This takes a Javascript function that gets called once the mol has been set. This allows you to release a lock that is set before setting the mol, so that this lock can be used to prevent setting a mol before the previous one has completed. The other part of the trick is to defer the setting of the molecule if the lock is present.
Click the "view online" of the attachment to see it in operation.
Thanks to the ChemAxon support for helping with this. First class support, as always.
The problem is that the simplistic approach of just stuffing the molecule into the MViewPane as a result of the onmouseover event caused problems when running in Internet Explorer when the mouse is moved rapidly over the hyperlinks. This problem was not seen with Mozilla. It is caused by the setM() method of the MViewPane being called before the previous setM() method had completed. Presumably the setM() method is not thread safe, and Internet Explorer does not handle this nicely, and either pops up error alerts, or worse still, freezes completely.
The trick is to check whether a molecule is already being set, and if so to defer the operation. After trying various ways of doing this the ChemAxon guys pointed out a neat parameter for MViewPane that helps here, the molChanged# param where # is the index of the mol in the MViewPane grid (e.g. 0, 1, 2...). This takes a Javascript function that gets called once the mol has been set. This allows you to release a lock that is set before setting the mol, so that this lock can be used to prevent setting a mol before the previous one has completed. The other part of the trick is to defer the setting of the molecule if the lock is present.
Click the "view online" of the attachment to see it in operation.
Thanks to the ChemAxon support for helping with this. First class support, as always.