Tuesday, May 22, 2012

How to Embed Mathematica CDF in a Blogger Blog Post

STEP 1:
In Blogger go to
Template-> Edit HTML-> Click "proceed" when warned about messing with your HTML

Insert the following code after <head>, like in the image below:
<script src='http://blog.wolfram.com/common/javascript/cdfplugin/1.0/cdfplugin.js?ver=2.8.4' type='text/javascript'/>

STEP 2:
Create a new post, and click Edit HTML for that post (different from the Edit HTML for the template), and then insert the following code into the body of your post where you want a CDF to appear:
<script type="text/javascript" src="http://www.wolfram.com/cdf-player/plugin/v2.1/cdfplugin.js"></script> <script type="text/javascript"> var cdf = new cdfplugin(); cdf.embed('http://blog.wolfram.com/data/uploads/2011/07/Animation11.cdf', 400, 300); </script>
 Then, publish your post, and it looks like this:

STEP 3:
Now to put your CDF in your blog, just change "http://blog.wolfram.com/data/uploads/2011/07/Animation11.cdf" to the URL to your CDF, and change the values "400, 300" = "width, height" to the values that best fit your blog.
I get my URL by uploading my CDFs to the "public" folder of my free Dropbox account, and copy-pasting the "public link" of the file.


8 comments:

  1. I don't understand why in my Blogger, some Mathematica cdf emb appear with a scroll bar that is very convenient for viewing. Some, doesn't have a scroll bar despite the original cdf file is very long....!!!?? IS there any explanation?

    ReplyDelete
    Replies
    1. I'm not sure... whenever the CDF is larger than the "width,height" that I specify, it always automatically puts a scroll bar. Let me know if you figure it out

      Delete
    2. This is a sample.....the plugg-ins just doesn't put in a scroll bar...!

      http://hacaoidea.blogspot.com/2012/07/tap-huan-ai-so-tuyen-tinh.html

      Delete
    3. Is it not displaying everything that you want it to, ie it cuts off part of your CDF?
      Or do you just want the blog post to be shorter, and thus have a scroll bar for the CDF? How are you setting the size "width, height"?

      Delete
  2. It cuts off part of my CDF....:(

    ReplyDelete
  3. did this change? it doesn't work for me

    ReplyDelete
  4. I think this is a real great post.Really thank you! Much obliged.
    Mathematica

    ReplyDelete
  5. Good work. I tried this procedure for my blog name in All Url Opener. I also want to stop unwanted referrals. Thanks for sharing this information.

    ReplyDelete