From: Yingjie L. <Yin...@ms...> - 2011-03-30 06:04:00
|
Hi Jmolers, I have a very simple page with JmolApplet, which behaves differently in Firefox, IE and Safari. Basically I would like to obtain residue number from a text input area named "inputResno". Then I want to display the label of this residue, if exists, in the <div> tag named "myStatusBar". Here are the main elements in the HTML file. If Safari, this page behaves as expected. However, in Firefox and IE, it requires two or three clicks on the button to get the correct label. Here's the address of my webpage if it helps for you to see what I mean. http://scbx.mssm.edu/sitecomp/mypage.HTML Any help is highly appreciated. <script type="text/javascript"> function showResInfo() { var myResNo = document.getElementById("inputResno").value; var myMessage = "Resno: " + myResNo; document.getElementById("myStatusBar").innerHTML = myMessage; var jmolCommand = "myCenterCA = {"+myResNo+":*.ca/1.1}; "; jmolScript(jmolCommand); myMessage += "<br>Jmol command: " + jmolCommand; document.getElementById("myStatusBar").innerHTML = myMessage; var myLabel = jmolEvaluate("myCenterCA.label()"); myMessage += "<br>Label: " + myLabel; document.getElementById("myStatusBar").innerHTML = myMessage; } </script> and <INPUT TYPE="TEXT" id="inputResno" SIZE=5 > <INPUT TYPE="BUTTON" ID="useEntered" OnClick="showResInfo();" VALUE="submit"> <br><div id="myStatusBar" style="background: grey; width:400px">No info</div> By the way, here are my browser versions: Safari 5.0.4 on Mac OS X Firefox 3.6.13 on Windows XP Professional SP3 (in VMWare) IE 6.0 on Windows XP Professional SP3 (in VMWare) Yingjie |
From: Yingjie L. <Yin...@ms...> - 2011-03-30 06:38:54
|
Hi Jmolers, I just tried my webpage in Safari on a different computer. This time its behavior in Safari is similar to its behavior in IE and Firefox. But I still don't get the correct answers on first click. I wonder whether the problem is in jmolScript() function, or elsewhere. http://scbx.mssm.edu/sitecomp/mypage.HTML Any thoughts? Yingjie |
From: Robert H. <ha...@st...> - 2011-03-30 22:36:21
|
Problem is here: function showResInfo() { var myResNo = document.getElementById("inputResno").value; var myMessage = "Resno: " + myResNo; document.getElementById("myStatusBar").innerHTML = myMessage; var jmolCommand = "myCenterCA = {"+myResNo+":*.ca/1.1}; "; jmolScript(jmolCommand); myMessage += "<br>Jmol command: " + jmolCommand; document.getElementById("myStatusBar").innerHTML = myMessage; var myLabel = jmolEvaluate("myCenterCA.label()"); myMessage += "<br>Label: " + myLabel; document.getElementById("myStatusBar").innerHTML = myMessage; } the JmolScript function works asynchronously -- you are passing a request to Jmol to execute a command, but not requiring that Jmol do that immediately. Personally I would just use: function showResInfo() { var myResNo = document.getElementById("inputResno").value; var myMessage = "Resno: " + myResNo; document.getElementById("myStatusBar").innerHTML = myMessage; myMessage += "<br>Jmol command: " + jmolCommand; document.getElementById("myStatusBar").innerHTML = myMessage; var myLabel = jmolEvaluate("{"+myResNo+":*.ca/1.1}.label()"); myMessage += "<br>Label: " + myLabel; document.getElementById("myStatusBar").innerHTML = myMessage; } That is, don't follow a jmolScript with anything that requires it to be executed. Alternatively, you could use jmolScriptWait, which would wait until the script command has executed to continue. On Wed, Mar 30, 2011 at 1:03 AM, Yingjie Lin <Yin...@ms...> wrote: > Hi Jmolers, > > I have a very simple page with JmolApplet, which behaves differently in > Firefox, IE and Safari. > Basically I would like to obtain residue number from a text input area > named "inputResno". > Then I want to display the label of this residue, if exists, in the <div> > tag named "myStatusBar". > Here are the main elements in the HTML file. > > If Safari, this page behaves as expected. However, in Firefox and IE, it > requires two or three clicks on > the button to get the correct label. > > Here's the address of my webpage if it helps for you to see what I mean. > http://scbx.mssm.edu/sitecomp/mypage.HTML > > Any help is highly appreciated. > > <script type="text/javascript"> > function showResInfo() { > var myResNo = document.getElementById("inputResno").value; > var myMessage = "Resno: " + myResNo; > document.getElementById("myStatusBar").innerHTML = myMessage; > > var jmolCommand = "myCenterCA = {"+myResNo+":*.ca/1.1}; "; > jmolScript(jmolCommand); > myMessage += "<br>Jmol command: " + jmolCommand; > document.getElementById("myStatusBar").innerHTML = myMessage; > > var myLabel = jmolEvaluate("myCenterCA.label()"); > myMessage += "<br>Label: " + myLabel; > document.getElementById("myStatusBar").innerHTML = myMessage; > } </script> > > and > > <INPUT TYPE="TEXT" id="inputResno" SIZE=5 > > <INPUT TYPE="BUTTON" ID="useEntered" OnClick="showResInfo();" > VALUE="submit"> > <br><div id="myStatusBar" style="background: grey; width:400px">No > info</div> > > By the way, here are my browser versions: > Safari 5.0.4 on Mac OS X > Firefox 3.6.13 on Windows XP Professional SP3 (in VMWare) > IE 6.0 on Windows XP Professional SP3 (in VMWare) > > Yingjie > > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Jmol-users mailing list > Jmo...@li... > https://lists.sourceforge.net/lists/listinfo/jmol-users > -- Robert M. Hanson Professor of Chemistry St. Olaf College 1520 St. Olaf Ave. Northfield, MN 55057 http://www.stolaf.edu/people/hansonr phone: 507-786-3107 If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 |