Jump to content

Pop Up Window/print Preview


howardfan123
 Share

Recommended Posts

Does anyone out there know how i would copy select div id="one" or div class="tow" to a new window or pop up window so i can put a print button on that page. i have tried css and javascript and cant seem to figure it out. no problems with a new window but can't seem to get the contect to go there and i have no problem with the printing from the oraginal page but it prints out the whole page and not the div"sany dirction or ideas on a starting point would be great thank you

Link to comment
Share on other sites

Here is what you asked for:

var content = document.getElementById("my_div").innerHTML;var my_win = window.open("","win");my_win.document.write(content);my_win.document.close();

But be aware that pop-up blockers get stricter and stricter every time a browser gets revised.An alternative would be to create a media stylesheet that hides everything you don't want to print. Not so difficult if all your content is arranged in <div> elements. That would look something like this:

<style type="text/css">	@media print {		div.header, div.footer {			display: none;		}	}</style>*	*	*<body>	<div class="header">		 Don't print me	 </div>	 <div class="content">		 YES! PRINT ME!	 </div>	 <div class="footer">		 Don't print me	 </div> </body>

Link to comment
Share on other sites

would the sylte sheet open in a new windowand is there a way to tell it what you want to print instead of what you dont want to printhere is the page to show you http://www.allyscandle.com/homeshowdealerf...ards-joinus.htmi just want the white section to print out on a white piece of 8.5 x 11 paperif i can get a preview in another window that would be even better but it does not have to just thought it would be easyier to get the cards to open in a new window and print the window.

Link to comment
Share on other sites

If you want to put content in a new window, I showed you how.The style sheet trick is an alternative to opening a new window.Theoretically, you can use the media rule to tell the browser only what it should print, but in practice this could get very hard, especially if your page is disorganized. And that page you linked us to is VERY disorganized. It doesn't even show up in the latest Firefox beta. Nothing but the green background.

Link to comment
Share on other sites

You've heard of Firefox? It's a browser in competition with Explorer. Most developers recognize it as far superior to Explorer, because it adheres to standards, while Microsoft has not. A conservative estimate is that 30% of your visitors will come on Firefox. A beta version is simply a pre-release version. So I saw your page on a browser that will be released in 5-6 months or so.Microsoft publisher is a terrible environment to create pages in, because (among other reasons) it caters to the flaws in Explorer and tempts you (without your knowing about it) to use non-standard code that is only used by Explorer.The page looks okay in Safari, except that all the inputs are frozen.Your design itself is really pretty simple. Following best practices, you could duplicate it in 1-2 hours in a plain text editor. Assuming you know some HTML.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...