Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Print current page

Print current page

Scheduled Pinned Locked Moved JavaScript
javascripthtmlcsswpfsysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cgreathouse
    wrote on last edited by
    #1

    Hello I have a page that displays search results. I'm looking for a way to have those search results printed. However, there are some items (ads, menus, etc) that should not be printed. What I have so far is the results are sent to a new tab (using javascript) with the search results. All of the items that shouldn't be visible have been removed. However, only the text shows up. All the CSS styles and images aren't showing up. Since the results are already being displayed, I'm trying to avoid having the server execute the search again. Another thing to keep in mind, this is an SPA app (i.e. the URL never changes throughout the site). My guess is since the html is getting sent to a new tab, the root URL is not set. So when it comes to a relative path for the images, css and script files, it doesn't know how to build the full path. Does anyone know of a way to get this method to work? I know I can get this to work by having the server execute the search again, but I'm trying to see if there's a client side solution. Thanks!

    P 1 Reply Last reply
    0
    • C cgreathouse

      Hello I have a page that displays search results. I'm looking for a way to have those search results printed. However, there are some items (ads, menus, etc) that should not be printed. What I have so far is the results are sent to a new tab (using javascript) with the search results. All of the items that shouldn't be visible have been removed. However, only the text shows up. All the CSS styles and images aren't showing up. Since the results are already being displayed, I'm trying to avoid having the server execute the search again. Another thing to keep in mind, this is an SPA app (i.e. the URL never changes throughout the site). My guess is since the html is getting sent to a new tab, the root URL is not set. So when it comes to a relative path for the images, css and script files, it doesn't know how to build the full path. Does anyone know of a way to get this method to work? I know I can get this to work by having the server execute the search again, but I'm trying to see if there's a client side solution. Thanks!

      P Offline
      P Offline
      Peter_in_2780
      wrote on last edited by
      #2

      Look at CSS media queries. You should be able to serve the ads, etc, in something like

      ...

      and have

      @media print {
      .noprint {
      display : none
      }
      }

      or something similar in your CSS, so when the browser renders for printing, it will hide the ads, etc. You might need some fancy footwork elsewhere in your CSS to make things look right both on screen and paper. Cheers, Peter

      Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups