PrintWindow() [英] PrintWindow()

查看:74
本文介绍了PrintWindow()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 - 我使用了< a href =" javascript :printWindow()">< Print>< / a>

用于打印网页的功能,但我最近遇到了一个有趣的变体

,并希望有一些帮助重复它。不幸的是,

网页已经锁定了鼠标右键菜单和状态栏,所以我不能偷偷看看。


打印链接位于一个全彩色,网页友好的页面,但当一个

查看器点击链接时,一个b& w,打印机友好版本打开了非常好的
小窗口,然后像往常一样继续使用javascript :printWindow()"

函数。


怎么做我这样做?谢谢,

~OC~

解决方案

" OysterCracker" < oc@sc.rr.com>写道:

嗨 - 我使用了< a href =" javascript :printWindow()">< Print>< ; / A>


不要使用javascript :伪协议。

< URL:http://jibbering.com/ faq / #FAQ4_24>


我不知道printWindow函数,但我猜它叫window.print。

我假设你没有''写< Print>在HTML :)

打印网页的功能,但我最近遇到了一个有趣的变化,并希望有一些帮助重复它。不幸的是,
网页已经锁定了鼠标右键菜单和状态栏,所以我无法偷看。


给我链接,我会在十秒钟内找到你的代码(我使用

Opera不允许网络页面删除)。或者,

你可以在学习页面时关闭Javascript。

打印链接位于一个全彩色,网页友好的页面,但当一个
查看器点击链接,一个b& w,打印机友好版本在一个非常小的窗口打开,然后照常进行使用javascript :printWindow()"
函数。




为什么不使用带有media =的不同样式表?打印?


不过,它没什么特别的。他们打开页面打开

window.open。加载的页面本身在完成加载时调用它的window.print函数

(例如< body onload =" window.print()">)。

顺便说一句,我搜索了printWindow。并且发现了同样糟糕的脚本a

几次(包括href =" javascript :"调用它的方法和

经常也脚本标签内的一堆HTML注释):

---

< SCRIPT LANGUAGE =" JavaScript">

< ; - 开始

函数printWindow(){

bV = parseInt(navigator.appVersion);

if(bV> = 4 )window.print();

}

//结束 - >

< / script>

---

这在很多不同的方面都很可怕,我不知道从哪里开始。以下将做同样的事情,只有更安全,并且在任何

新浏览器中使用appVersion< 4:

---

< script type =" text / javascript">

function printWindow(){

if(window.print){

window.print( );

}

}

< / script>

---


/ L

-

Lasse Reichstein Nielsen - lr * @ hotpop。 com

Art D''HTML:< URL:http://www.infimum.dk/HTML/randomArtSplit.html>

''信仰没有判断只会降低精神神圣。''


" OysterCracker" < oc@sc.rr.com>在留言中写道

news:h1 ********************* @ twister.southeast.rr。 com ...

嗨 - 我使用了< a href =" javascript :printWindow()">< Print>< /一个>
打印网页的功能,但我最近遇到了一个有趣的变化,并希望有一些帮助重复它。不幸的是,
网页已经锁定了鼠标右键菜单和状态栏,所以我无法偷看。

打印链接位于一个全彩色,网页友好的页面,但当
a查看器点击链接时,一个b& w,打印机友好版本在一个非常小的窗口中打开,然后像往常一样继续javascript :printWindow()"
功能。

我该怎么做?谢谢,
~OC~



唯一知道的方法是查看来源。


顺便说一下,那里没理由你不能看源代码。如果他们

禁用右键单击并且这是您的浏览器允许查看源代码的唯一方式,请执行以下操作:


1.右键单击页面或框架,然后*按住*鼠标按钮。

2.弹出对话框打开时告诉您无法右键单击,按

" Enter"键盘上的键。

3.现在,释放鼠标按钮,你就会得到你的右键菜单

就像什么都没发生一样。

您也可以禁用JavaScript,或使用下拉菜单查看来源。


要回答您的问题,最简单的解决方案(假设网站是

数据库后端)提供可打印版本的Web内容是

来处理服务器端的所有内容。 JavaScript和CSS可以做到这一点,但它是非常不可靠的,并且很难在每个人的浏览器上工作。我已经开发了许多商业网站,他们想要一个可打印版本的所有内容,并且实现多个渲染非常简单

格式通过我服务器的执行环境(在我的情况下是PHP)。


HTH,

Zac




" Zac Hester" <是ne ** @ planetzac.net>在消息中写道

news:3f ******** @ news.enetis.net ...

" OysterCracker" < oc@sc.rr.com>在消息中写道
新闻:h1 ********************* @ twister.southeast.rr。 com ...

嗨 - 我使用了< a href =" javascript :printWindow()">< Print>< /一个>
打印网页的功能,但我最近遇到了一个有趣的变化,并希望有一些帮助重复它。不幸的是,

网页已经锁定了鼠标右键菜单和状态栏,所以
我无法偷看。

;打印和QUOT;链接位于一个全彩色,网页友好的页面上,但当

查看器点击链接时,
,一个b& w,打印机友好版本在

中打开
非常小的窗口,然后像往常一样继续使用
" javascript :printWindow()"功能。

我该怎么做?谢谢,
~OC~



唯一知道的方法就是查看来源。

顺便说一下,没有你不能看源代码的原因。如果他们禁用右键单击并且这是您的浏览器允许查看源代码的唯一方式,请执行以下操作:

1.右键单击页面或框架并且*按住*鼠标按钮。
2.当弹出对话框打开告诉您无法右键单击时,按



输入 ;键盘上的键。



废话


如果上下文事件被告知不要解雇它,Zac的意思是

他不能阻止你给别人的菜单。阻止事件发生是非常基本的。

这里有一个例子,你会发现我的页面上没有这样的东西。我

还设置了一个界面,您可以在其中输入您需要查看的网址

并且它将为您显示代码

3现在,释放鼠标按钮,你就会得到你的右键菜单,就像什么也没发生一样。

你也可以禁用JavaScript,或者使用下拉菜单来查看
source。
要回答你的问题,最简单的解决方案(假设网站在后端数据库)提供可打印版本的网络内容
是处理服务器端的所有内容。 JavaScript和CSS可以做到这一点,但是
它非常不可靠,很难在每个人的浏览器上运行。
我已经开发了许多商业网站,他们想要所有
内容的可打印版本,通过我的服务器执行实现多种渲染格式非常简单环境(在我的情况下是PHP)。

HTH,
Zac



Hi - I''ve used the <a href="javascript:printWindow()"><Print></a>
function for printing a webpage, but I ran into an interesting variation
recently, and would appreciate some help duplicating it. Unfortunately, the
webpage had locked out both the right-mouse menu and the status bar, so I
couldn''t sneak a peek.

The "Print" link was located on a full-color, web-friendly page, but when a
viewer clicked the link, a b&w, printer-friendly version opened in a very
small window, then proceeded as usual with the "javascript:printWindow()"
function.

How do I do that? Thanks,
~OC~

解决方案

"OysterCracker" <oc@sc.rr.com> writes:

Hi - I''ve used the <a href="javascript:printWindow()"><Print></a>
Don''t use the javascript: pseudo protocol.
<URL:http://jibbering.com/faq/#FAQ4_24>

I don''t know the printWindow function, but I guess it calls window.print.
I assume you don''t write "<Print>" in HTML :)
function for printing a webpage, but I ran into an interesting variation
recently, and would appreciate some help duplicating it. Unfortunately, the
webpage had locked out both the right-mouse menu and the status bar, so I
couldn''t sneak a peek.
Give me the link, and I''ll have the code for you in ten seconds (I use
Opera which don''t allow the web page to remove either). Alternatively,
you could just have turned Javascript off while studying the page.
The "Print" link was located on a full-color, web-friendly page, but when a
viewer clicked the link, a b&w, printer-friendly version opened in a very
small window, then proceeded as usual with the "javascript:printWindow()"
function.



Why not just use a different stylesheet with media=print?

Still, it''s nothing fancy. They just open the page with a call to
window.open. The loaded page itself calls its window.print function
when it is finished loading (e.g. <body onload="window.print()">).
Btw, I searched for "printWindow" and found the same lousy script a
few times (including the href="javascript:" method of calling it and
often also a bunch of HTML comments inside the script tag):
---
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}
// End -->
</script>
---
This is horrible in so many different ways that I don''t know where to
begin. The following will do the same, only safer and working in any
new browsers with appVersion<4:
---
<script type="text/javascript">
function printWindow(){
if (window.print) {
window.print();
}
}
</script>
---

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D''HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
''Faith without judgement merely degrades the spirit divine.''


"OysterCracker" <oc@sc.rr.com> wrote in message
news:h1*********************@twister.southeast.rr. com...

Hi - I''ve used the <a href="javascript:printWindow()"><Print></a>
function for printing a webpage, but I ran into an interesting variation
recently, and would appreciate some help duplicating it. Unfortunately, the webpage had locked out both the right-mouse menu and the status bar, so I
couldn''t sneak a peek.

The "Print" link was located on a full-color, web-friendly page, but when a viewer clicked the link, a b&w, printer-friendly version opened in a very
small window, then proceeded as usual with the "javascript:printWindow()"
function.

How do I do that? Thanks,
~OC~


The only way to know is to look at the source.

By the way, there''s no reason you can''t look at the source code. If they
disable right-clicking and that really is the only way your browser allows
you to view source, do this:

1. Right-click on the page or frame and *hold* the mouse button down.
2. When the pop-up dialog opens telling you you can''t right-click, press the
"Enter" key on your keyboard.
3. Now, release the mouse button and you will have your right click menu
just like nothing ever happened.

You could also disable JavaScript, or use the pull-down menu to view source.

To answer your question, the easiest solution (assuming the site is
databased on the backend) to providing printable versions of web content is
to handle everything server-side. JavaScript and CSS can do this, but it''s
very unreliable and is difficult to get working on everyone''s browser. I''ve
developed many commercial web sites who wanted a printable version of all of
their content, and it was very simple to just implement multiple rendering
formats through my server''s execution environment (in my case PHP).

HTH,
Zac



"Zac Hester" <ne**@planetzac.net> wrote in message
news:3f********@news.enetis.net...

"OysterCracker" <oc@sc.rr.com> wrote in message
news:h1*********************@twister.southeast.rr. com...

Hi - I''ve used the <a href="javascript:printWindow()"><Print></a>
function for printing a webpage, but I ran into an interesting variation
recently, and would appreciate some help duplicating it. Unfortunately, the

webpage had locked out both the right-mouse menu and the status bar, so I couldn''t sneak a peek.

The "Print" link was located on a full-color, web-friendly page, but when a

viewer clicked the link, a b&w, printer-friendly version opened in a

very small window, then proceeded as usual with the "javascript:printWindow()" function.

How do I do that? Thanks,
~OC~


The only way to know is to look at the source.

By the way, there''s no reason you can''t look at the source code. If they
disable right-clicking and that really is the only way your browser allows
you to view source, do this:

1. Right-click on the page or frame and *hold* the mouse button down.
2. When the pop-up dialog opens telling you you can''t right-click, press


the "Enter" key on your keyboard.

nonsense

if the context event has been told not to fire it wont, what Zac meant was
he cannot stop you geting the menu others can. stopping a event firing is
very basic.
here is a example, you will see that no such thing is possible on my page. I
have also set up a interface where you can enter your URL you need to see
and it will present the code for you
3. Now, release the mouse button and you will have your right click menu
just like nothing ever happened.

You could also disable JavaScript, or use the pull-down menu to view source.
To answer your question, the easiest solution (assuming the site is
databased on the backend) to providing printable versions of web content is to handle everything server-side. JavaScript and CSS can do this, but it''s very unreliable and is difficult to get working on everyone''s browser. I''ve developed many commercial web sites who wanted a printable version of all of their content, and it was very simple to just implement multiple rendering
formats through my server''s execution environment (in my case PHP).

HTH,
Zac



这篇关于PrintWindow()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆