Pages

Thursday, April 29, 2010

Simple Javascript Tester

When ever I work with javascript, I often have to test small functions. When working on cumbersome tasks, testing for smaller functions becomes a pain.

So in order to test them I developed this small useful tool.

Just copy and paste the following code into your html page, and there you go you get the tool that will work,

<textarea style="height: 300px; width: 600px;" id="scriptContainer"></textarea>

<button type="button" onclick="eval(document.getElementById('scriptContainer').value)">Evaluate</button>


In Xpages Context, Create a Custom Control, go to the source code panel, delete all the code that you see there, and copy paste the following code into it.This will give you a simple client side javascript tester tool.

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

    <xp:inputTextarea id="scriptContainer" style="height:300.0px;width:600px"></xp:inputTextarea>
    <xp:br></xp:br>
    <xp:button value="Evaluate" id="button1">
        <xp:eventHandler event="onclick" submit="false">
            <xp:this.script><![CDATA[eval(document.getElementById('#{id:scriptContainer}').value)]]></xp:this.script>
        </xp:eventHandler></xp:button>
</xp:view>


You can also test your javascript code here,


Hope this helps :)

No comments:

Post a Comment