As the title says... And also: Can the text file be any extension other than .txt I have done this using flash, need to know if it can be done using JS
The only way I know that it can be done is to use ajax to load the file which will return it as a string variable. The file has to be on a resolvable path on your web site. I have seen it done with .txt, .html, .json etc.... sorry don't have any sample code handy but that is where I would start looking
hi, you mean load the contents of a text file ( or any file ) ? If yes, you can try PHP's file_get_contents: <?php $content = file_get_contents('some_text_file.txt'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script type="text/javascript"> var some_var = '<?php echo $content?>'; window.onload = function() { document.getElementById('content').innerHTML = some_var; } </script> </head> <body> <div id="content"></div> </body> </html> PHP: * you should sanitize the $content first or add some js functions to clean the output -Loibe