473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Forcing the user to open a link in a special way.

I want to realize the following....

The user logs in to a certain webpage (username & password).
Then the user sees a html page with a link in it.
This link is a target="_blank" link, so it would open in a new Internet
Explorer window.
Normally the user has the possibility to go on that link (without clicking
with left mousebutton),
pressing the right mouse button, going on copy location, open a new
browserwindow by
himself (even if it is a totally other browsertype),
copy the link location in it, and access the url of the link in this manner.

I want to prevent this. He should only be able to open the link by pressing
the left mousebutton,
otherwise he should have to log in again.

Is this possible, if yes - how?
A.G.


Oct 6 '06 #1
8 1581
Axel Gallus wrote:
The user logs in to a certain webpage (username & password).
Then the user sees a html page with a link in it.
This link is a target="_blank" link, so it would open in a new Internet
Explorer window.
[...]
He should only be able to open the link by pressing
the left mousebutton, otherwise he should have to log in again.

Is this possible, if yes - how?
It is impossible with PHP.

--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot
Oct 7 '06 #2
To disable the context menu (right-click or context key), you can use
this:

<body oncontextmenu="return false;">

See here for more info:
http://javascript.about.com/library/blnoright.htm

In addition, you can check the referrer URL which will block some
attempts to access the page by just pasting the URL in the browser.
(This can be circumvented by the user however because the referrer can
be spoofed.) Here's an example:

function checkReferrer($uriPath)
{
$from = '#^https?://' . preg_quote($_SERVER['HTTP_HOST']) .
'((?-i)' . preg_quote($uriPath) . ')$#i';
if (!isset($_SERVER['HTTP_REFERER']) ||
!preg_match($from, $_SERVER['HTTP_REFERER'])) {
die();
}
}

//
// Pass the path to your referrer script here:
//

checkReferrer('/path/to/script.php');

Best Regards,

John Peters

Axel Gallus wrote:
I want to realize the following....

The user logs in to a certain webpage (username & password).
Then the user sees a html page with a link in it.
This link is a target="_blank" link, so it would open in a new Internet
Explorer window.
Normally the user has the possibility to go on that link (without clicking
with left mousebutton),
pressing the right mouse button, going on copy location, open a new
browserwindow by
himself (even if it is a totally other browsertype),
copy the link location in it, and access the url of the link in this manner.

I want to prevent this. He should only be able to open the link by pressing
the left mousebutton,
otherwise he should have to log in again.

Is this possible, if yes - how?
A.G.
Oct 7 '06 #3
pe*******@gmail.com wrote:
To disable the context menu (right-click or context key), you can use
this:

<body oncontextmenu="return false;">

See here for more info:
http://javascript.about.com/library/blnoright.htm

In addition, you can check the referrer URL which will block some
attempts to access the page by just pasting the URL in the browser.
(This can be circumvented by the user however because the referrer can
be spoofed.) Here's an example:

function checkReferrer($uriPath)
{
$from = '#^https?://' . preg_quote($_SERVER['HTTP_HOST']) .
'((?-i)' . preg_quote($uriPath) . ')$#i';
if (!isset($_SERVER['HTTP_REFERER']) ||
!preg_match($from, $_SERVER['HTTP_REFERER'])) {
die();
}
}

//
// Pass the path to your referrer script here:
//

checkReferrer('/path/to/script.php');

Best Regards,

John Peters

Axel Gallus wrote:
>>I want to realize the following....

The user logs in to a certain webpage (username & password).
Then the user sees a html page with a link in it.
This link is a target="_blank" link, so it would open in a new Internet
Explorer window.
Normally the user has the possibility to go on that link (without clicking
with left mousebutton),
pressing the right mouse button, going on copy location, open a new
browserwindow by
himself (even if it is a totally other browsertype),
copy the link location in it, and access the url of the link in this manner.

I want to prevent this. He should only be able to open the link by pressing
the left mousebutton,
otherwise he should have to log in again.

Is this possible, if yes - how?
A.G.

Which fails miserably if the user has disabled javascript.

There is no foolproof way to do it.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 7 '06 #4
pe*******@gmail.com:
To disable the context menu (right-click or context key), you can use
this:

<body oncontextmenu="return false;">
How rude!

(You would need to modify your DTD as well, since no version of HTML
allows the attribute oncontextmenu.)

--
Jock

Oct 7 '06 #5
*** pe*******@gmail.com escribió/wrote (6 Oct 2006 18:22:52 -0700):
In addition, you can check the referrer URL which will block some
attempts to access the page by just pasting the URL in the browser.
(This can be circumvented by the user however because the referrer can
be spoofed.)
Last but not least, you must check $_SERVER['USER_AGENT'] to filter out
whoever is not using Internet Explorer as desired. It is not bulletproof
but, at this point, any Firefox or Opera user will have probably left the
site.
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Oct 8 '06 #6
Following on from 's message. . .
>pe*******@gmail.com:
>To disable the context menu (right-click or context key), you can use
this:

<body oncontextmenu="return false;">

How rude!
Agreed.
>
(You would need to modify your DTD as well, since no version of HTML
allows the attribute oncontextmenu.)
I thought this was a load of bull but strangely when I tried it in
Firefox (with js enabled) it worked.


--
PETER FOX Not the same since the statuette business went bust
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Oct 8 '06 #7
Peter Fox wrote:
Following on from 's message. . .
>pe*******@gmail.com:
>>To disable the context menu (right-click or context key), you can use
this:

<body oncontextmenu="return false;">


How rude!

Agreed.
>>
(You would need to modify your DTD as well, since no version of HTML
allows the attribute oncontextmenu.)
I thought this was a load of bull but strangely when I tried it in
Firefox (with js enabled) it worked.

Disable js...

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 8 '06 #8
Jerry is right. You can use those deprecated or unsupported stuff in most
browsers because they are quite forgiving.

But, just disable javascript and *poof* your whole scheme is gone. Also,
thanks to extensions like GreaseMonkey, someone could just disable
javascript for your site or even just for a single page on your server.

I also have a one-click on/off switch for javascript right in my toolbar on
FireFox. Took 15 seconds to install.
Perhaps better would be the reason you want to prevent this.. If you are
trying to stop people from saving your web content, then your only option is
not to generate web content. For what reason do you want to block this action?

Peter Fox wrote:
>
I thought this was a load of bull but strangely when I tried it in
Firefox (with js enabled) it worked.
Oct 8 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff...
18
by: MuZZy | last post by:
Hi, I got a situation here :) an dwonder if someone can help me. I have an MDI app and say, the child form has a button, clicking on which calls a database transaction - grabbing a lot of tables...
0
by: Mike P | last post by:
Hi, I am trying to implement on an ASP.NET page that when a user clicks on a file link, it forces the Save/Open box in the browser. I have managed to do this (with a little help from this...
6
by: G Dean Blake | last post by:
in my aspx app I am writing a stream that works fine but it replaces what is in the client browser window. The code is as follows: .. .. HttpContext.Current.Response.ClearHeaders()...
9
by: newcomsas | last post by:
Hello. I'm working on a problem related with CSS and javascript: I have got a link on a page and a stylesheet file that makes the background color change when users click on it. Is there...
4
by: teeBull | last post by:
Hi all, We'd like to take advantage of code we already have for transforming XML into HTML (using XSLT) for our users to save the HTML as an MS Word document locally. I've dug around and found...
158
by: Giovanni Bajo | last post by:
Hello, I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the "PSF infrastracture committee", after weeks of evaluation, recommends...
4
by: mrouleau | last post by:
I am sorry if this is the wrong group to ask, if so please point me in the correct direction. My problem is I have an MDB file with user-level security on it (mdw). When i move it over to a...
3
by: Don | last post by:
Is it possible to create a link which will cause either A) the server to serve a fresh copy of a file or B) the browser to "refresh" the copy of the file. Doing it via a link is the only...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.