I'm trying to just display the output (return result) of a function using document.write, but it doesn't seem to work. Here's a really simple example... function some_function(abc) { return abc; } document.write(some_function('Hello world')); Code (markup): Yet if I replace "document.write" with "alert", it works just fine (except I don't want an alert box...) function some_function(abc) { return abc; } alert(some_function('Hello world')); Code (markup):
It works for me: <script type="text/javascript"> function some_function(abc) { return abc; } document.write(some_function('Hello world')); </script> HTML:
Try wrapping the code in Try-Catch and see what your browser has to say: <script language="javascript"> try { function some_function(abc) { return abc; } document.write(some_function('Hello world')); } catch(e) { alert(e); } </script> HTML:
Solved it with "document.getElementById('divname').innerHTML=function();" & creating labeled div tags. Thanks though.