MathEdit API Library to interact with the MathEdit tool--Open a new window

Each MathML Expression must have a unique id. You can apply different operations to a drawing via its id.

MathEdit APIs to interact with the MathEdit tool

  1. New a MathML Expression hide

    mathedit.newMath( id, parentId );
    id: the id of a math expression. A new <embed> element with this id will be created.
    parentId: the id of the element on which the above <embed> element will be appended.

    Example:

    <p id="newmath1"/>
    <input id="btn1" type="button" value="New Math Expression" 
     onclick="mathedit.newMath( 'd1', 'newmath1' );" />
    

    Click this button to create a new math expression here.

    Your Entered Math Expression:

  2. Edit a Math Expression by ID hide

    mathedit.editMathById( id );
    id: the id of a math expression. If a non-exist math expression id is provided, an error message will pop up.

    Example:

    <input id="btn2" type="button" value="Edit Math Expression"
     onclick="mathedit.editMathById( 'd1' );" />
    

    Click this button to edit the above math expression.

  3. Get MathML content code  hide

    mathedit.get('mathContent');

    Example:

    <input id="btn3" type="button" value="Get MathML Content Code"
     onclick="mathedit.get('mathContent');" />
    

    Click this button to get the Content code of math expression.

  4. Get Infix expression code  hide

    mathedit.get('mathInfix');

    Example:

    <input id="btn4" type="button" value="Get Infix Code"
     onclick="mathedit.get('mathInfix');" />
    

    Click this button to get the Infix code of math expression.

  5. Get MathML presentation code  hide

    mathedit.get('mathPresentation');

    Example:

    <input id="btn5" type="button" value="Get MathML Presentation Code"
     onclick="mathedit.get('mathPresentation');" />
    

    Click this button to get the MathML Presentation code of math expression.

  6. Edit a Math Expression by Code hide

    mathedit.editMath(Str,cType,tID,pID)
    Str: the content code or infix code of a math expression.
    cType: the type of code ('1':the content code;'2':infix code).
    tID: the ID of a new math expression.
    pID: the ID of target container(html element) which display math expression.

    Example:

    <p id="newmath2"/>
    <input id="btn6" type="button" value="Edit Math Expression" 
     onclick="mathedit.editMath(document.getElementById('mcode').value,'1','d2','newmath2');" />
    

    Please input math expression code(must be content code because the value of "cType" is '1'):

    Click this button to edit math expression.

    the Math Expression: