|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
JavaScript not working.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 Is this JS before the body tag or at the end of page?
Put it at the end, this way your whole document will be loaded before you access any tags. http://www.netomatix.com Show quoteHide quote "tshad" <tscheider***@ftsolutions.com> wrote in message news:uz%231%23xceGHA.3364@TK2MSFTNGP05.phx.gbl... >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 Show quoteHide quote "Winista" <naveenko***@hotmail.com> wrote in message news:eQ4NyBdeGHA.380@TK2MSFTNGP04.phx.gbl... > Is this JS before the body tag or at the end of page? > Put it at the end, this way your whole document will be loaded before you > access any tags. > > http://www.netomatix.com > > "tshad" <tscheider***@ftsolutions.com> wrote in message > news:uz%231%23xceGHA.3364@TK2MSFTNGP05.phx.gbl... >>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 >> > >
Other interesting topics
|
|||||||||||||||||||||||