JavaScript not working.

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I have an ASP.net page where I am trying print the page directly from a
printer. The only way I can figure out how to do this is in Javascript with
PrintDomTree.

The problem is that I don't get anything back when using a getElementByID.
It is null. The ID is there.

Here is the JavaScript:

****************************
function printDOMTree(destinationWindow)
{
// Use destination window to print the tree. If destinationWIndow is
// not specified, create a new window and print the tree into that
window

alert("Inside printDOMTree");
var domElement = document.getElementById('MainTable');
if (domElement == null)
alert("domElement == null");
else
alert ("domElement != null");
************************************************

I get the alert back that says domElement is null.

Here is the tag:

<DIV ID="MainTable">

And you can see it when you viewsource.

What am I missing?

Thanks,

Tom
 
This was my mistake.

I just found that it was print the other message. Brain Fade for a moment.

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top