Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
|
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2007, 07:26 AM
Registered User
 
Join Date: Apr 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Printing the content inside the div tag

I want to print the content in the a div tag. I have tried that somewhre i read of copying the content in the divtag to a window object. And print that new window. But in that it is opening a new window. But i dont want a new window to be opened.

The code i refered is as follows

function printSpecial()
{
    if (document.getElementById != null)
    {
        var html = '<HTML>\n<HEAD>\n';

        if (document.getElementsByTagName != null)
        {
            var headTags = document.getElementsByTagName("head");
            if (headTags.length > 0)
                html += headTags[0].innerHTML;
        }

        html += '\n</HEAD>\n\n';

        var printReadyElem = document.getElementById("printReady");

        if (printReadyElem != null)
        {
                html += printReadyElem.innerHTML;
        }
        else
        {
            alert("Could not find the printReady function");
            return;
        }

        html += '\n</BODY>\n</HTML>';

        var printWin = window.open("","printSpecial");
        printWin.document.open();
        printWin.document.write(html);

        if (gAutoPrint)
        {
            printWin.print();

        }


    }
    else
    {
        alert("The print ready feature is only available if you are using an browser. Please update your browswer.");
    }
}

Can any one suggest a better way

Pooja





Similar Threads
Thread Thread Starter Forum Replies Last Post
Content page DIV tag problem msbsam ASP.NET 2.0 Professional 0 September 19th, 2008 12:12 AM
div tag as link Stagmo Dreamweaver (all versions) 0 April 14th, 2006 12:35 AM
DIV TAG marclena ASP.NET 1.0 and 1.1 Professional 2 May 24th, 2005 11:14 AM
disable <div> content (everything inside it!) crmpicco Javascript How-To 2 April 12th, 2005 09:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.