Open In App

Embedding an online compiler into a website

Last Updated : 09 Dec, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

How to add a JDoodle compiler into a website?

Using the JDoodle compiler we can write our code in C, C++, Java, and in many more programming languages, and then we can embed and easily run that program in our webpage by giving standard inputs, and we can give command line arguments also.

Steps to follow:

Step 1: Open the website JDoodle.com and sign in, if you don’t have an account then you must register first.

Step 2: Select any one programming language and write your code and save it. Click on editable share and copy the embed URL.

Step 3: On your website page insert the div and script tags as follows:

The below code will create a division and embed the compiler into a website page.      

<div data-pym-src="paste copied URL here."></div>

The below code will include the JavaScript code from the JDoodle. Include the below code at the bottom of the website page.

<script src=”https://www.jdoodle.com/assets/jdoodle-pym.min.js” type=”text/javascript”></script>

Example: Following is an example of embedding a C++ compiler.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>
        Embedding an online compiler 
        into a website
    </title>
</head>
  
<body>
    <!-- It will create a division for 
        compiler and embed that into 
        web page-->
    <div data-pym-src=
    </div>
  
    <!-- This script tag contains the 
        javascript code in the written URL -->
    <script src=
        type="text/javascript">
    </script>
</body>
  
</html>


Output:

Note: We can also hide the stdin inputs and command-line arguments by putting ?stdin=0&arg=0 at the end of the URL in the <div> tag. Here, stdin=0 is to hide stdin inputs and arg=0 to hide command line arguments. In order to enable it, just change ‘0’ by ‘1’.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads