image from marvinjs

User 151fddb1df

27-05-2015 07:50:36

Hi,


 


I have an instance of marvinjs on a web page to sketch a molecule and I wanted to  get an image of this molecule. So I tried the code below and it worked just fine.


var marvinSketcherInstance;

$(document).ready(function handleDocumentReady (e) {
// get the reference to the Marvin JS editor
MarvinJSUtil.getEditor("#sketch").then(function (sketcherInstance) {
marvinSketcherInstance = sketcherInstance;
initControl();
},function (error) {
alert("Cannot retrieve sketcher instance from iframe:"+error);
});
});

function initControl () {

// the export button
$("#btn-export").on("click", function (e) {
var settings = {
'width' : 150,
'height' : 150
};
marvinSketcherInstance.exportStructure("jpeg", settings).then(function(source) {
exportImage(source);
}, function(error) {
alert("Image export failed:"+error);
});
});
}

function exportImage(dataUrl) {
// set image source for the existing hidden image tag and display it.
$("#image").attr("src", dataUrl);
$("#imageContainer").css("display", "inline-block");
}


 


However, I want to dislay this image on another webpage so I tried to put the url in an variable but once on the other webpage it's gone (even if put in a session variable). I also tried with the function molToDataUrl but so far even if I'm able to have the url on the webpage diplaying the sketcher, I loose it as soon as I'm not on this page anymore.


Do you have any idea on how I should to display this image on a different web page than the one diplaying the sketcher please ? Maybe I'm missing a step here ?


 


Thanks for your help :)


 



ChemAxon 996dedebe0

27-05-2015 08:31:53

Dear Labbe,


I think you have 2 options:



You can learn more abput post and get methods here: http://www.w3schools.com/tags/ref_httpmethods.asp


Regards,


Janos

User 151fddb1df

27-05-2015 13:17:40

Dear Janos,


 


thanks for your answer. I already tried to store the url via the post method and it worked contrary to what I said.  I've finally identified the problems . It seems the first one was due to a replacement of the "+" of the url by a space (Oo) and a syntaxe probleme that was easier to find once the url was correct. So now it works !


Thanks again for your help


 


Regards

ChemAxon 76c88f5366

28-05-2015 07:40:52

Dear Labbe,


Thank you for your reply. Please, let us know if any further question arises.