<script type="text/javascript">

function getpr(txt2){
alert("I'm in");

function message()
var doc = new ActiveXObject("Word.Application"); // creates the word object
doc.Visible=false; // doesn't display Word window
doc.Documents.Open("C:\\Users\\vinay\\Desktop\\HTMLPages\\test\\pr.txt"); // specify path to 
//copy the content from my word document and throw it into my variable
txt = doc.Documents("C:\\Users\\vinay\\Desktop\\HTMLPages\\test\\pr.txt").Content; 
//alert("PR number is Set to :" + prnumber + "!");
doc.quit(0); // quit word (very important or you'll quickly chew up memory!)



<body onload="message()">

Above script getpr() function is not working it is printing
but document.write(prnumber); is printing

Your function prints the variable passed to it, and you pass it the value of doc.Documents("C:\\Users\\vinay\\Desktop\\HTMLPages\\test\\pr.txt").Content; I would imagine that's returning a null or undef value. Also, be careful with document.write in the head, best to use innerHTML to set content of existing elements. :)