So far I have read that some things are not supported in CDFs. Istvan-zachar mentioned very useful things in his post. Unfortunately he mentioned that

This is taken straight from wolfram.com under the "Interactivity in .cdf Files" section. In the past I was messing around with MathLink because I wanted to create functions that would execute faster. For an example of a complete MathLink program look at this old post of mine. In there I created an interactive program that uses the MathLink program. The question now, regardless of what wolfram says about no support for MathLink operations is,

Has anyone been able to export this type of programs? Is it possible to embed the MathLink program in the cdf file? If not, can we make the cdf file create the link to the MathLink program?

I suppose that we need to be aware that if this is possible then it would only work in computers running the same operating system that compiled the MathLink program. That is, if I compiled in Mac OS X, then the CDF would not run properly under Windows.

# Update:

Thanks to Mark McClure now I know how to make the function available to the cdf document. The problem now is that I get this:

Only after I click on Enable Dynamics the desired result:

This tells me that the CDF was able to load the MathLink program but it will not let it run. I'm aware that this is do to security. I was reading here about the trusted path. Well, instead of adding a path I moved the cdf file and the MathLink program to a trusted directory. If I open it with Mathematica then it opens with no problem. But, if I were to open it with the CDF Player then I run into the issue I just mentioned. It requires me to click on the "Enable Dynamics" button. I believe this is what makes the CDF not being able to be displayed online. Any thoughts?

-
This demonstration loads a function from a DLL file. (But the DLL file is already part of Mathematica and has a fixed path in the \$InstallationDirectory---it's from TetGenLink.) –  Szabolcs May 28 '12 at 8:09

As per your request here is a way you can run this as an embedded CDF. The problem you have described is that a CDF embedded on a webpage can, in some circumstances, be considered untrusted and therefore raises a security flag. To get around this you need to make the "enable dynamics" button appear so the user can allow the dynamic content to run. This button will appear when you run a CDF in full screen mode so you need to tell an embedded CDF to run as full screen mode. The way to do that is to add an undocumented option {fullscreen:'true'} to the javascript that gets created by the CDF wizard:

<script src="http://www.wolfram.com/cdf-player/plugin/v2.1/cdfplugin.js" type="text/javascript">
</script>
<script type="text/javascript">
var cdf = new cdf_plugin();
cdf.embed("http://path.to/myCDF.cdf", 500, 600,{fullscreen:'true'});
</script>

-
@MH. Thx. The {fullscreen:'true'} option solves the problem (for me) and i'd even say unlocks the potential of CDF on the web. But isn't there another keyword that makes the 'enable dynamics' button appear without all the full top bar (useless and ugly in the context of a cdf embedded in a web page)? I'm surprised this is undocumented as anybody who tries to put CDFs on the web will face this problem.. –  Oscar6E Aug 26 '12 at 21:44
@MH. On second thought, the good thing about displaying the full top bar is it contains a save button, so a reader can download the cdf and run it as a stand alone application, outside the browser... Now it seems to me the best, in terms of security/flexibility, would be just to display those two buttons 'enable dynamics' and 'save' a bit more nicely. Almost there ! –  Oscar6E Aug 27 '12 at 17:22

In my experience, MathLink and J/Link can be easily accessed in CDF using either Mathematica or CDF Player. I've attached a screenshot of a MathLink dependent dynamic running in CDF Player.

Of course, there's no guarantee of future compatibility.

-
How do you make the cdf player avoid the dynamic content warning? I think this is what it prevents the cdf file from being viewed in an html file. –  jmlopez May 16 '12 at 6:31