Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to have students submit articles that include Mathematica demonstration projects in a document that is on Google sites. I am having problems with embedding the JS code. Could you provide step-by-step instructions. Not sure of the tag for this question.

share|improve this question

1 Answer 1

There is no need to use Javascript to include CDF in a web page.

Upload the CDF file (source.cdf) and the HTML page (index.htm) into a folder on the server. Keep both files in same folder for simplicity.

Edit the index.htm file using a text editor and type this line in the HTML anywhere you want the CDF to show up and play in the web page:

   <embed src="source.cdf" width="800" height="700"> 

Change the width and height to the correct values as needed so the the content area reserved on the web page matches well with the size of the display you want.

If this still does not work for you, please follow up with error messages. Make sure to use CDF export from Mathematica, using Standalone option.

enter image description here

From comment below, may be there is some confusion, so I thought I make the steps more clear.

Here are the steps:

1 Student needs Mathematica to make CDF

2 Student starts Mathematica, opens new notebook, makes HW assignment and Manipulate in the notebook.

3 Student exports the notebook to CDF file as standalone. Now there are 2 files in student folder on their PC (university computer or student own computer). one file is called hw.nb and one called hw.cdf

4 Student makes an index.htm file using a text editor, here is a template for one to use:

<!DOCTYPE html> 
<html> 
<head>
<title>my HW</title> 
</head><body>

 <div> <embed src="hw.cdf" width="800" height="700"> </div>

</body> 
</html>

5 Now there are 3 files in student folder hw.nb, hw.cdf and index.htm

6 Student uploads the files hw.cdf and index.htm to server, on a folder there. Keeping both files in same folder on server.

share|improve this answer
    
So I need to have Mathematica license itself and open the CDF file in it and then export it as a standalone? –  Maesumi Nov 29 '13 at 19:45
    
@Maesumi You need Mathematica to create CDF file from notebook file. i.e Mathematica is need for the step nb->cdf. Then CDF is used on the web page, not the .nb file. You do not need Mathematica to use CDF file. Only to create one. –  Nasser Nov 29 '13 at 20:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.