JavaScript Tester

Type your custom Javascript Code:

Here is the code:

<script type="text/javascript">
* @param tagAttributesObj keyvalue object with the attributes of the script tag
* @param codeAsTex a string that contains the javascript code
* @param divName The div ID where the script is going to be inserted (optional)
* @return {Number} Id of the script tag
function appendScript(tagAttributesObj, codeAsText, divName){
    var newScript = "<span style='display:none;'>.</span>";
    // Create openning tag
    var tagId = "scriptId" + Math.ceil(Math.random() * 10000);
    if(tagAttributesObj != null){
        newScript += "<SCRIPT id='"+ tagId +"' ";
        for(var a in tagAttributesObj){
            newScript += a +"='"+ tagAttributesObj[a] +"' ";
        newScript += "DEFER>";
        newScript += "<SCRIPT type='text/javascript' DEFER>";
    // Add new script
    if(codeAsText != null) newScript += codeAsText;
    // Close script tag
    newScript += "</SCRIPT" + ">";
    // Append to DOM
    if(divName != null){
        var container = document.getElementById(divName);
             container.innerHTML = newScript;
        var container = document.createElement("div");
             container.innerHTML = newScript;
    return tagId;
function insertCustomScript(){
    var txt = document.getElementById('ta');
    var scr = txt.value;
    appendScript(null, scr);

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

IMPORTANT! To be able to proceed, you need to solve the following simple math (so I know that you are a human) :-)

What is 5 + 6 ?
Please leave these two fields as-is: