Angel,

Looking at the Jmol.js file I noticed that there was only one place where the Document.write was used so I thought I would just try changing this rather than overriding it. Here is the code.

function _jmolDocumentWrite(text) {
  if (_jmol.currentDocument)
    var newcontent = document.createElement('div');
    newcontent.appendChild(document.createTextNode(text));
    document.body.insertBefore(newcontent, null);
//    _jmol.currentDocument.write(text);

So I think this is very similar to what you were suggesting. What is happening is that all of the text is inserted into the web page as text, i.e.- it isn't interpreted as markup so no applet is loaded. So I think I am getting close, but I haven't figured out why it is doing this or how to get around it.

Incidentally, the svg is working and the page is validating. Neither Safari 4 nor Firebug report any errors.


***********************************************
Jeff Hansen
Department of Chemistry and Biochemistry
DePauw University
602 S. College Ave.
Greencastle, IN 46135
jhan...@depauw.edu
***********************************************


On May 6, 2009, at 9:36 PM, Angel Herráez wrote:

OK, I couldn't resist to dig into this.
I am having partial success by overrriding the
function _jmolDocumentWrite(text)
present in Jmol.js, with a new definition:

Add this to the header of your page AFTER the call to Jmol.js:
<script type="text/javascript">
function _jmolDocumentWrite(text)
{           // Override Jmol.js
  if (_jmol.currentDocument)
  {  //_jmol.currentDocument.write(text); //this is what Jmol.js uses
     /* This is the new code, slightly adapted (A.H.) from
                        the addElement() function at 
https://developer.mozilla.org/en/document.createElement
LICENSE: Code samples in MDC wikis are available under the terms of
                        the MIT License, 
http://www.ibiblio.org/pub/Linux/LICENSES/mit.license
             */
            // 1. Create a new div element and give it some content:
            var newDivForJmolJs = document.createElement("span");
            newDivForJmolJs.innerHTML = text;
// 2. Add the newly created element and it's content into the DOM:
            document.body.insertBefore(newDivForJmolJs, null);
// (Firefox and Opera require the 2nd argument, even if null)
  }
  return text;
}
</script>

jmolApplet() works (Firefox, Opera, Chrome, Safari, all in WinXP)
jmolLink() work
jmolButton(), jmolRadioGroup() and jmolMenu(): depends on the browser




------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. 
http://p.sf.net/sfu/kodak-com_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to