How to avoid opening a new window with the shift key?

C

Carlos Andr?s

Hi everybody.

I've got a problem. I'd like to avoid opening a new window when you
have pressed the shift key and you click in the left button of the
mouse. I've tried the next solution, in the body of the page I put the
next code:

<BODY onkeydown='notOpenNewWindow();'>


And I wrote this javascript function:

function notOpenNewWindow(){
if (window.event.keyCode=='16'){
window.event.keyCode = 0;
window.event.returnValue = false;
}

But this solution is wrong because the new window is opened.

Could anybody help me?

Thanks,

Carlos.
 
R

Randy Webb

Carlos said:
Hi everybody.

I've got a problem. I'd like to avoid opening a new window when you
have pressed the shift key and you click in the left button of the
mouse. I've tried the next solution, in the body of the page I put the
next code:

Then redesign your page so that it doesn't break when its opened in a
new window. What happens if I right click and "Open in new window"?
 
K

kaeli

Then redesign your page so that it doesn't break when its opened in a
new window. What happens if I right click and "Open in new window"?

What happens when I middle mouse click in Mozilla or Opera? ;)
(hint to OP: I set it up so middle mouse click opens links in a new
window)

--
 
I

Ivo

(e-mail address removed) enlightened us with...
What happens when I middle mouse click in Mozilla or Opera? ;)
(hint to OP: I set it up so middle mouse click opens links in a new
window)

And what if I press Ctrl-N? And what if I get so annoyed by these clueless
pointless scripts that I disable script altogether?
Design your page to allow these browser tricks, that is the way of the web.
You don't give us the reason you think you need to do disable this, my guess
is because it 's weak and/or not well thought through.
Amen,
Ivo.
 
C

Carlos Andr?s

This web is an internal application and my company have decided that
this function doesn't work in the application. The right button of the
mouse also is disabled. This is the reason.

I was looking for some help but I've only found critiques.
 
M

Matt Kruse

Randy said:
No, you got advice. And then you come back and say "oh, its for an
intranet app", which is fine. But the default assumption is its for
the web, and on the web, the answers you got are the only answers to
get.

I think this is flawed thinking, and it's littering this newsgroup.

The default assumption for a (well-worded) question should always be that
the OP has a justified reason to do what he or she is trying to do, and is
looking for an answer to the QUESTION, not general discussion on the
correctness of their design decision. (In some cases, the posting style of
the original post makes it obvious that the OP has no clue about what they
are really asking).

If someone has an answer to the original question, or can point the person
in the right direction, and _then_ decides to also note that there are
potential problems with the idea, then that's great.

But, having multiple followups all telling the OP that they are dumb to even
think about doing what they're doing, all making the assumption that the OP
is too stupid to know it's probably a bad idea to do this in an internet
environment, is elitist behavior that reduces the effectiveness of the
group. IMO.
 
J

Julie

Randy said:
No, you got advice. And then you come back and say "oh, its for an
intranet app", which is fine. But the default assumption is its for the
web, and on the web, the answers you got are the only answers to get.

He didn't ask for advice, he asked for answers.

If respondents could simply answer the question (presuming that they _have_ an
answer), and leave the critiques and advice for later, it sure would make it
easier to get _answers_ to questions.

Honestly, it doesn't matter whether or not the intended target is intranet,
internet, or anything else. The OP had a specific question, and respondents
felt that (for whatever reason) it was their prerogative to provide advice,
commentary, and critiques.
Since it is an intranet app, go to each PC and edit the registry and
remove the entry that deals with the browsers and the ability to
shift-click to open a new window.

And read the FAQ, with regards to posting, providing information, and
posting replies (top-posting) and trimming.

Respondents: read the original question, and answer _THAT_.
 
I

Ivo

An intranet, I didn't know that, that changes things, but not all things.
And it still doesn't say why they want this disabled. A good reason would be
the revelation of sensitive data, something that breaches security or so, is
there a problem like that? Then it may be time to redesign the whole site.
Reason?


No, you got advice. And then you come back and say "oh, its for an
intranet app", which is fine.

My earlier advice could very well be taken as critique (I think your company
sucks) as well as as a warning. And a genuine one. Unless you have divine
control over each computer in your intranet, you do not know what browsers
may be used, and you don't know all the ways new windows can be opened.
Someone could type in the addressbar:

javascript: na=window.open();na.document.open();na.document.write
(document.documentElement.outerHTML);na.document.close();

which simply duplicates the current window (in some browsers) regardless of
any script in the page, or

javascript:for(var (i=document.links).length;i--;) i.target="_blank";

to make all links open in a new window just like that, even without shifts.

Again, it is the way of the web, also the intraweb.These technologies are
not as one-dimensional as some people, especially people in companies,
appear to think sometimes. If this is your job, you should explain these
things to whomever asked you this script, since they clearly have no idea.
Also disabling the right mouse button does not sound like a good idea. Don't
you ever want to copy something, add a page to your bookmark list, etc. etc.
It is counter-productive, really (I 'm sure your superiors are sensitive to
an argument like that). Because anything you think you have disabled has
only become a bit more cumbersome, but remains possible. I repeat: disabling
the contextmenu disables nothing except the user's sympathy.
But the default assumption is its for the
web, and on the web, the answers you got are the only answers to get.

Since it is an intranet app, go to each PC and edit the registry and
remove the entry that deals with the browsers and the ability to
shift-click to open a new window.

Javascript is capable of detecting shifts and clicks. It is probably not
difficult to write a script that cancels or changes the default action
associated with a shift-click, but for this situation I don't see the point.
HTH
Ivo
 
L

Lee

Matt Kruse said:
The default assumption for a (well-worded) question should always be that
the OP has a justified reason to do what he or she is trying to do, and is
looking for an answer to the QUESTION, not general discussion on the
correctness of their design decision.


In my experience, very few posters who ask for help doing
something foolish or evil realize that there's any problem.

The few who do will almost immediately respond to criticism
with one of:

I know it's bad, but my boss wants it.
or
I know it would be bad on the Internet,
but this is a special case.

When an ignorant developer does something stupid on the web,
it hurts all of us. I don't like helping them to do that.
 
L

Lee

Carlos Andr?s said:
This web is an internal application and my company have decided that
this function doesn't work in the application. The right button of the
mouse also is disabled. This is the reason.

The correct way to handle that is to tell your users
not to open the links in new windows. If the problem
is so serious that opening a new window breaks something,
then you have a design problem that you shouldn't be
trying to hack around in the user interface.
 
R

Richard Cornford

Matt said:
I think this is flawed thinking, and it's littering this newsgroup.

In the event of an OP choosing not to explain the context of their
question some assumption has to be made in order to answer at all. The
FAQ for this group states what the default assumption is, and in the
case of most of the questions asked it is the correct assumption to
make.

If people don't want to be subject to that assumption then they should
follow the detailed advice on the efficient asking of questions provided
in the FAQ.
The default assumption for a (well-worded) question should always be
that the OP has a justified reason to do what he or she is trying to
do, and is looking for an answer to the QUESTION, not general
discussion on the correctness of their design decision. (In some
cases, the posting style of the original post makes it obvious that
the OP has no clue about what they are really asking).

It is somewhat typical that the criteria you would apply would be the
wording of the question. I read the OP and immediately thought that some
incompetent jelly has created an application/back-end that is not suited
for use over HTTP with a web browser front end and is now looking for a
javascript Band-aid in an effort to fix the wrong problem (and I have
seen nothing that has changed my mind).

You would have the OP provided with that band-aid, even though the best
it could do is lessen the problem. I would want whoever wrote the
back-end to be directed toward design and implementation criteria
suitable for HTTP application programming, so at least the next time
they create one this problem wouldn't exist.

The wording has little to do with the response, the asking of this
question is itself an indicator that the OP does not understand what
they are asking for, or its implications.
If someone has an answer to the original question, or can point the
person in the right direction, and _then_ decides to also note that
there are potential problems with the idea, then that's great.

(Yet you want to have your say without positing a single line of code or
word of explanation that addresses the OP's situation.)

There is no right direction in which to point, except back to the
back-end and having it's inadequacies fixed. There is no cross-browser
solution, and any possible IE only solution would not reduce the
stupidity of potentially reducing the productivity of users of the
system by denying them the tools they are used to using in a web
browser.
But, having multiple followups all telling the OP that they are dumb
to even think about doing what they're doing, all making the
assumption that the OP is too stupid to know it's probably a bad idea
to do this in an internet environment, is elitist behavior that
reduces the effectiveness of the group. IMO.

I can see why you may feel that it elitist to recognise and point out
fundamentally flawed design, but your personal standards are not those
of the majority of the regulars on this group.

Incidentally, saying "reduces the effectiveness of the group" implies
that the group has a purpose, it does not, this group does no more than
exist and exhibit behaviour. Insofar as anything approaching a purpose
exists for the group it is no more than to discuss javascript, which is
adequately satisfied by stating that javascript is unsuitable for some
things, or that some things are an extremely bad idea to attempt with
javascript.

The existence of the group has side effects, one of which is much
javascript related problem solving, another is an ever improving
understanding of the use and application of javascript on the part of
its regular contributors (through exposing their explanations, ideas and
scripts to the strongly critical environment of the group), but nobody
has a right to expect (and certainly not demand) anything from the group
as a whole.

Richard.
 
R

Richard Cornford

Julie wrote:
Honestly, it doesn't matter whether or not the intended target is
intranet, internet, or anything else. The OP had a specific
question, and respondents felt that (for whatever reason) it was
their prerogative to provide advice, commentary, and critiques.
<snip>

So long as responses are on-topic for the group then it _is_ their
prerogative to provide advice, commentary and critiques. That is Usenet;
open, public and free.

If you want the right to demand specific answers to specific questions
then you should expect to pay for those answers, otherwise you will get
what you get.

Richard.
 
L

Lee

Julie said:
He didn't ask for advice, he asked for answers.

If respondents could simply answer the question (presuming that they _have_ an
answer), and leave the critiques and advice for later, it sure would make it
easier to get _answers_ to questions.

Honestly, it doesn't matter whether or not the intended target is intranet,
internet, or anything else. The OP had a specific question, and respondents
felt that (for whatever reason) it was their prerogative to provide advice,
commentary, and critiques.

And, of course, that is their prerogative, and that's a good
thing, because very often advice, commentary and critiques
are more valuable than answering the original question.

If somebody asks the best technique to use to clean a shotgun
without unloading it, would you be doing them a service by
figuring out some solution that might work, if they're very
careful?

Badly written web applications damage the reputations of all
web application developers.
 
K

kaeli

This web is an internal application and my company have decided that
this function doesn't work in the application. The right button of the
mouse also is disabled. This is the reason.

Really? You do know I can simply change my mouse to be left-handed and
then left click, right?

Your company either hires the mentally challenged or kids fresh out of
school (or maybe both). They get what they pay for. Actually, this
sounds like our lovely time tracking application here where I work. It's
a POS.

I'd be more than happy to freelance and write them a nice, robust
application that won't break from such simple things. Give me more
money, and I'll make sure *nothing* breaks it. ;)
I was looking for some help but I've only found critiques.

Poor baby. *world's smallest violin playing in background*
*grin*

--
 
R

Robert

The right button of theHere is how a user can reenable the right mouse button.

riki said:
and disable right click

See this article for two additonal ways to re-enable the mouse button:

http://groups.google.com/groups?q=e...ring=d&[email protected]&rnum=4

I've copied one below too. I think it is so interensting that you can
run Javascript from the command line.

Robert

Grant Wagner said:
~greg wrote:

If by "bookmarklet" you mean a Favorite that executes code via the
javascript: psuedo-protocol

<snip>

This works!
javascript:function a(){document.body.oncontextmenu=null;document.onmousedown=null;window.onmousedown=null;}a();

thanks,
~greg

All the user has to do is bookmark this javascript line an run it by
clicking on the bookmark.

You may not like the advise, but you are not accomplishing what you
expect from disabling the keys because the user can get around your
limits. Thus whatever you are trying to protect is exposed.

Robert
 
J

Julie

Richard said:
I can see why you may feel that it elitist to recognise and point out
fundamentally flawed design, but your personal standards are not those
of the majority of the regulars on this group.

They aren't personal standards -- they are a part of living in a civilized
society -- empower the individual.

There is no majority rule that pertains to this forum.
 
J

Julie

Richard said:
Julie wrote:

<snip>

So long as responses are on-topic for the group then it _is_ their
prerogative to provide advice, commentary and critiques. That is Usenet;
open, public and free.

If you want the right to demand specific answers to specific questions
then you should expect to pay for those answers, otherwise you will get
what you get.

So you feel that it is inappropriate for someone to expect and answer to a
question, but more appropriate for respondents to separately arrive at
unfounded conclusions and provide unsubstantiated and unwarranted critiques?
 
J

Julie

Lee said:
Julie said:

And, of course, that is their prerogative, and that's a good
thing, because very often advice, commentary and critiques
are more valuable than answering the original question.

If somebody asks the best technique to use to clean a shotgun
without unloading it, would you be doing them a service by
figuring out some solution that might work, if they're very
careful?

I don't see why not? Are you self-presuming some level of authority and
capacity or control over the individual asking the question? Protect them from
themselves?
Badly written web applications damage the reputations of all
web application developers.

I don't disagree.

However, I'd be very interested to know how you were able to determine that
that it was a 'badly written web application' strictly from:

I've got a problem. I'd like to avoid opening a new window
when you have pressed the shift key and you click in the
left button of the mouse.

Either you have incredible powers of targeted analysis and reasoning, or you
made an assumption.
 
L

Lee

Julie said:
Lee wrote:

I don't see why not?

Because it would be irresponsible.

Main Entry: ir·re·spon·si·ble
Pronunciation: "ir-i-'spän(t)-s&-b&l
Function: adjective : not responsible: as
a : not answerable to higher authority <an irresponsible dictatorship>
b : said or done with no sense of responsibility <irresponsible accusations>
c : lacking a sense of responsibility
d : unable especially mentally or financially to bear responsibility

I don't disagree.

However, I'd be very interested to know how you were able to determine that
that it was a 'badly written web application' strictly from:

I've got a problem. I'd like to avoid opening a new window
when you have pressed the shift key and you click in the
left button of the mouse.

Either you have incredible powers of targeted analysis and reasoning, or you
made an assumption.

It is completely reasonable to assume that any application that
requires standard controls to be disabled is badly written.

The poster always has the opportunity to appeal that decision
by giving more information.

On the other hand, once we have helped somebody to create a bad
application, we have no such appeal process to prevent them from
deploying it.
 
L

Lee

Julie said:
They aren't personal standards -- they are a part of living in a civilized
society -- empower the individual.

Our civilized society empowers us to choose not to help people
to create designs that we believe are bad.
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top