Post code to JDoodle
Sometimes you do not want an editor in your page. You want your own styled code block, and a button that opens it in JDoodle.
Post to JDoodle does that with an HTML form. There is no API to integrate and no JavaScript to write.
How it works
Show the code on your page however you like. When a reader chooses your button, their browser posts the code to JDoodle, which opens it in the editor ready to run.
<form action="https://www.jdoodle.com/api/redirect-to-post/online-java-compiler" method="post">
<textarea name="initScript" rows="8" cols="80"></textarea>
<input type="submit" value="Open in JDoodle" />
</form>Two parts matter:
- The language. It is the last part of the address. Replace
online-java-compilerwith the language you want. - The
initScriptfield. It carries the code. Whatever is in it opens in the editor.
Finding the language name
The name in the address is the same one JDoodle uses in its own URLs. Open the
language on JDoodle and take it from the address bar. For example
c-online-compiler for C, or python3-programming-online for Python 3.
When to use it
Post to JDoodle
Your code block, your styling, and a button that hands the code over. The reader continues on JDoodle.
Good for a site with its own design, and for code you only need readers to run occasionally.
An embed
The editor runs inside your page. The reader never leaves.
Good for tutorials and documentation where running the code is part of reading.
The difference is where the reader ends up. Post to JDoodle sends them to us. An embed keeps them with you.
What next
If you want the editor running in your page instead, so readers never leave, that is an embed.