最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to remove url text from page printed using javascript's window.print() function - Stack Overflow

programmeradmin0浏览0评论

Here is my code where I am opening a new window by clicking on a anchor tag. It navigates to try1.php and once clicking on it, it will go to try1.php. (The code is given in the second code.

try.php

     <script type="text/javascript">
     function newwin() 
     {
       myWindow=window.open('try1.php','myWin','width=400,height=650')
      }
   </script>
   </head>
   <body>
   <a onclick="newwin()">click </a>
   </body>

The code for try1.php is given below

   <body>
   <input type="submit" value="print Data"  onClick="window.print()"/>
   </body>

in try1.php, I am having a button on which I have apllied onclcck event. When I click on the button it prints the data but also prints the url text which I don't want.

May I know the way to remove the url text from the printed page?

Here is my code where I am opening a new window by clicking on a anchor tag. It navigates to try1.php and once clicking on it, it will go to try1.php. (The code is given in the second code.

try.php

     <script type="text/javascript">
     function newwin() 
     {
       myWindow=window.open('try1.php','myWin','width=400,height=650')
      }
   </script>
   </head>
   <body>
   <a onclick="newwin()">click </a>
   </body>

The code for try1.php is given below

   <body>
   <input type="submit" value="print Data"  onClick="window.print()"/>
   </body>

in try1.php, I am having a button on which I have apllied onclcck event. When I click on the button it prints the data but also prints the url text which I don't want.

May I know the way to remove the url text from the printed page?

Share Improve this question edited Mar 14, 2014 at 12:03 disfated 11k13 gold badges41 silver badges52 bronze badges asked Mar 14, 2014 at 11:55 user3138522user3138522 1113 gold badges4 silver badges13 bronze badges 4
  • Adjust the browser print settings. – VisioN Commented Mar 14, 2014 at 11:57
  • howtogeek./howto/the-geek-blog/… – Hüseyin BABAL Commented Mar 14, 2014 at 11:58
  • is there any other way like is there any code to remove that ??? – user3138522 Commented Mar 14, 2014 at 11:59
  • @user3138522 you can do that with media-dependent style sheets. See my answer – Hüseyin BABAL Commented Mar 14, 2014 at 12:04
Add a ment  | 

1 Answer 1

Reset to default 2

You can do that with media-dependent style sheets like below;

 <link rel="stylesheet" type="text/css" media="print,handheld" href="your.css"/>

And in your your.css;

@media print {
    a {
        display:none;
    }
 }

 @media screen and projection {
    a {
        display:inline;
    }
  }
发布评论

评论列表(0)

  1. 暂无评论