a. ) Already can be anywhere you put it on the page. Just pretend the entire script is an image tag. Place it wherever you want it, in a paragragh or table etc.
b. ) Javascript cannot close a window that javascript did not open. If you open your window using the window.open() method:
HTML Code:
<a href="somepage.htm" onclick="window.open(this.href);return false;" target="_blank">Some Page</a>
Then you can close it using the self.close() method:
Code:
function printit(){
if (window.print) {
window.print() ;
} else {
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "";
}
self.close();
}
However this may interfere with the printing. If so, a time out could be used but, even that, in certain circumstances, might not be enough.
Bottom line on this second question is, unless you open the window using the window.open() method and test the live page under low bandwidth situations and the self.close() doesn't halt the print job, don't bother with it.
Bookmarks