var keyword is used to declare a local variable within a function. that means you are using var cmd in main() function, so it is only accessible in main() function only; same is the case with var enarg for more info about javascript variable scope you can go to w3schools.com
you can get it working by just removing var before cmd and enarg, but i would recommend passing those values to run() function as parameters /arguments like this:
Code:
function main(){var inputdata=document.getElementById('text1').value;
var part=inputdata.split('_');
var cmd=part[0];
var arg=part[1];
var enarg=encodeURIComponent(arg);
run(cmd,enarg);return false;}
function run(cmd,enarg){
if(cmd=='g'){g();};
if(cmd=='gi'){gi();};
if(cmd=='wiki'){w();};
if(cmd=='al'){al();};}
function g(){location.href='http://google.com/search/?q='+enarg}
function gi(){location.href='http://googld.com/images/?q='+enarg}
function w(){location.href='http://en.wikipedia.org/wiki/speacial:search/?search='+enarg}
function al(){alert('+arg+')}
Bookmarks