PrintWindow()

O

OysterCracker

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~
 
L

Lasse Reichstein Nielsen

OysterCracker said:
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 said:
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>
 
Z

Zac Hester

OysterCracker said:
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
 
M

Mosley Jones III

Zac Hester said:
when


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
 
L

Lasse Reichstein Nielsen

Zac Hester said:
What are you labeling as "nonsense?" My method of subverting "right-click
trapping" or his inability to view the source of a given web page?

Your method, if I read him right.
Just write
<body oncontextmenu="return false">
in a page and try your method. No pop-up dialog at all, works in both
IE and Mozilla (and should be a hanging offense in real pages, ofcourse).

He is, however, a little too confident in that method, since turning
off javascript will stop it cold. Who cares, though, there is no
functionality in the normal context menu that isn't available through
the menu anyway.

....
Post a URL to your page that claims to be able to hide the source code from
a visitor, and I'll have a look. If I can't get to your code, this round is
on me.

Pretty much a safe bet.

Not even encryption, as long as it is decrypted clientside, will stop
a determined attacker.

/L
 
Z

Zac Hester

Lasse Reichstein Nielsen said:
Your method, if I read him right.
Just write
<body oncontextmenu="return false">
in a page and try your method. No pop-up dialog at all, works in both
IE and Mozilla (and should be a hanging offense in real pages, ofcourse).

He is, however, a little too confident in that method, since turning
off javascript will stop it cold. Who cares, though, there is no
functionality in the normal context menu that isn't available through
the menu anyway.

I saw that method on some hacker-ese page once. I found it funny since they
had all kinds of JavaScript traps that I learned how to use by looking right
at their code. They even packaged up all their JavaScript in nice,
easy-to-download external script files. It's been a while, but I'm pretty
sure Konquerer (Gecko-based, I think) didn't fire the oncontextmenu event.
However, I seem to remember using a browser on Windows that didn't fire the
event either. (Maybe an old version of Netscape or something.)
Additionally, has anyone on a Mac OS had problems with context-sensitive
menus employing this trick?

The method I suggested was based on my experience of 99% of those pages that
try to lock out the context menu by simply popping up an alert box. The
casual visitor becomes disoriented by this and decides that there must not
be a way to use the context menu. The person trying to quickly view the
source of an internal frame, learns that this method is easier than digging
through the Internet cache.

Take care,
Zac
 
M

Mosley Jones III

Zac Hester said:
I saw that method on some hacker-ese page once. I found it funny since they
had all kinds of JavaScript traps that I learned how to use by looking right
at their code. They even packaged up all their JavaScript in nice,
easy-to-download external script files. It's been a while, but I'm pretty
sure Konquerer (Gecko-based, I think) didn't fire the oncontextmenu event.
However, I seem to remember using a browser on Windows that didn't fire the
event either. (Maybe an old version of Netscape or something.)
Additionally, has anyone on a Mac OS had problems with context-sensitive
menus employing this trick?

yes only yesterday you were informing a user that all he has to do is hod
down the mouse button while he presses the enter button on the keyboard.

Yo made a error, but in your quest to hide this you have attracted attention
to yourself
 
Z

Zac Hester

Mosley Jones III said:
yes only yesterday you were informing a user that all he has to do is hod
down the mouse button while he presses the enter button on the keyboard.

Yo made a error, but in your quest to hide this you have attracted attention
to yourself

My initial method ONLY works on pages that only trap the right-click event
in IE and Mozilla (and possibly others). If you want to count that against
me, go ahead. I made a _huge_ mistake in assuming that this person was
trying to view a page that was trying to trap the right mouse click (like
many I have personally encountered). I am sorry, you may flame me at will.

Obviously, the OP isn't as interested in this thread as we are since he
never did tell us how the page was blocking his attempt to view the source.

A nice biproduct of our discussion is that a lot of other people have shared
their methods of access a stubborn web page's source. Not all is lost.

Many thanks for your (hopefully) helpful criticism,
Zac
 
Z

Zac Hester

Mosley Jones III said:
using


Ohhh so now you are changing your story?

In the English language there's such a thing as a modifying clause. A
person makes a statement that is supposed to state a broad, sweeping fact,
then the statement is refined to be more precise in meaning via a clause.
When I say, "All icecream tastes good (except for pralene)," I'm doing the
same thing. You start by making an absolute statement and follow it with
any notable exceptions. It allows you to get the details out of the way
without cluttering the overall meaning of a statement. If this seems to be
a subvertive tactic on my part, I apologize. My intentions were sincere.
I'm not interested in your second guesses. I really don't care

If it helps, there's a feature in "X-Newsreader: Microsoft Outlook Express
6.00.2800.1158" that allows you to block all the posts from a given person:

"Message" -> "Block Sender..." -> "Yes"

Just highlight one of my posts and block me. That should fix a lot of
things. You won't have to put up with my "second guesses" anymore. It's
apparent that there's nothing you can learn from me, so I can't think of a
reason why you haven't already blocked me.

Most sincerely,
Zac
 
M

Mosley Jones III

Zac Hester said:
My initial method ONLY works on pages that only trap the right-click event
in IE and Mozilla (and possibly others). If you want to count that against
me, go ahead. I made a _huge_ mistake in assuming that this person was
trying to view a page that was trying to trap the right mouse click (like
many I have personally encountered). I am sorry, you may flame me at will.

Obviously, the OP isn't as interested in this thread as we are since he
never did tell us how the page was blocking his attempt to view the source.

A nice biproduct of our discussion is that a lot of other people have shared
their methods of access a stubborn web page's source. Not all is lost.

Many thanks for your (hopefully) helpful criticism,
Zac


No problems Zac
 
O

OysterCracker

Obviously, the OP isn't as interested in this thread as we are since he
never did tell us how the page was blocking his attempt to view the source.

My apologies to the ng. I was interested, and got good early feedback
regarding a simple, suitable solution for me. This ng is a valuable resource
and I don't mean to abuse it. At the same time, my interest was in the
solution, not in how to bypass their block on the source code. This thread
quickly took a turn in that direction. The url was a secure financial site
that required passwords I was not willing to share, so I didn't see any
benefit in providing the url. I also had no intentions of starting WWIII...
if I had any spare valium, I'd be glad to share it but I need all I have.
Thanks again for the help.
~OC~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,077
Messages
2,570,567
Members
47,202
Latest member
misc.

Latest Threads

Top