Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #25590 > unrolled thread

Disable viewing outside of frame set

Started byen2 <nijePravi@mail.com>
First post2014-07-30 11:05 +0200
Last post2014-07-31 09:50 +0200
Articles 10 — 7 participants

Back to article view | Back to comp.lang.javascript


Contents

  Disable viewing outside of frame set en2 <nijePravi@mail.com> - 2014-07-30 11:05 +0200
    Re: Disable viewing outside of frame set danca <cyberdanny@tiscalinet.it> - 2014-07-30 15:47 +0200
    Re: Disable viewing outside of frame set Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-30 17:04 +0200
      Re: Disable viewing outside of frame set Andrew Poulos <ap_prog@hotmail.com> - 2014-07-31 09:52 +1000
        Re: Disable viewing outside of frame set Huub de Beer <H.T.de.Beer@gmail.com> - 2014-07-31 08:26 +0200
          Re: Disable viewing outside of frame set en2 <nijePravi@mail.com> - 2014-07-31 08:53 +0200
            Re: Disable viewing outside of frame set Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-07-31 12:46 +0100
              Re: Disable viewing outside of frame set Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-31 14:56 +0200
    Re: Disable viewing outside of frame set JJ <jj4public@vfemail.net> - 2014-07-31 14:11 +0700
      Re: Disable viewing outside of frame set en2 <nijePravi@mail.com> - 2014-07-31 09:50 +0200

#25590 — Disable viewing outside of frame set

Fromen2 <nijePravi@mail.com>
Date2014-07-30 11:05 +0200
SubjectDisable viewing outside of frame set
Message-ID<lrachh$p3v$1@l01news1.ot.hr>
Hi to all.

I didn't work with html or javascript for quite sometime and i can not 
remember how to solve this.

Basically what i want to do is to block to prevent user on accessing 
single web page out of the main frame frameset.

E.g. if the page is www.thePage.com and if the menu link is cars.html
i want to redirect user to prevent viewing this page outside of 
frameset. So if he makes copy of this link and passes it on new tab like
www.thePage/cars.html, he should be redirected to www.thePage.com

Thnx in advance !

[toc] | [next] | [standalone]


#25592

Fromdanca <cyberdanny@tiscalinet.it>
Date2014-07-30 15:47 +0200
Message-ID<lrat1a$jh2$1@dont-email.me>
In reply to#25590
Il 30/07/2014 11:05, en2 ha scritto:
> Hi to all.
>
> I didn't work with html or javascript for quite sometime and i can not
> remember how to solve this.
>
> Basically what i want to do is to block to prevent user on accessing
> single web page out of the main frame frameset.
>
> E.g. if the page is www.thePage.com and if the menu link is cars.html
> i want to redirect user to prevent viewing this page outside of
> frameset. So if he makes copy of this link and passes it on new tab like
> www.thePage/cars.html, he should be redirected to www.thePage.com
>
> Thnx in advance !

Maybe something like this?
<script>
function whereAmIRunning(){if (top=windows) location.href=location.host
</script>
<body onload="whereAmIRunnig()">
Dan

[toc] | [prev] | [next] | [standalone]


#25593

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-07-30 17:04 +0200
Message-ID<2978035.TjpaFmbO7j@PointedEars.de>
In reply to#25590
Stefan Ram wrote:

> en2 <nijePravi@mail.com> writes:
>> frameset. So if he makes copy of this link and passes it on new tab like
> 
>   Maybe something like:
> 
> if( top.location.href.toLowerCase() === "www.example.com/cars.html" )
> top.location.href = "example.com";
> 
>   . But this would only work in case that someone had enabled JavaScript.

Please don't.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#25594

FromAndrew Poulos <ap_prog@hotmail.com>
Date2014-07-31 09:52 +1000
Message-ID<756dnSD9VJd3GETOnZ2dnUVZ_jWdnZ2d@westnet.com.au>
In reply to#25593
On 31/07/2014 1:04 AM, Thomas 'PointedEars' Lahn wrote:
> Stefan Ram wrote:
>
>> en2 <nijePravi@mail.com> writes:
>>> frameset. So if he makes copy of this link and passes it on new tab like
>>
>>    Maybe something like:
>>
>> if( top.location.href.toLowerCase() === "www.example.com/cars.html" )
>> top.location.href = "example.com";
>>
>>    . But this would only work in case that someone had enabled JavaScript.
>
> Please don't.

When I read a response like this from someone who knows far more about 
coding than I do I'm unsure what the problem(s) might be. Do you not like:
- frames in general
- partial URLs
- frame busting protection
- "confusing" users by redirecting
- using JavaScript in this instance
- something else

Andrew Poulos

[toc] | [prev] | [next] | [standalone]


#25596

FromHuub de Beer <H.T.de.Beer@gmail.com>
Date2014-07-31 08:26 +0200
Message-ID<53d9e185$0$8398$703f8584@news.kpn.nl>
In reply to#25594
Andrew Poulos wrote:

> On 31/07/2014 1:04 AM, Thomas 'PointedEars' Lahn wrote:
>> Stefan Ram wrote:
>>
>>> en2 <nijePravi@mail.com> writes:
>>>> frameset. So if he makes copy of this link and passes it on new tab
>>>> like
>>>
>>>    Maybe something like:
>>>
>>> if( top.location.href.toLowerCase() === "www.example.com/cars.html" )
>>> top.location.href = "example.com";
>>>
>>>    . But this would only work in case that someone had enabled
>>>    JavaScript.
>>
>> Please don't.
> 
> When I read a response like this from someone who knows far more about
> coding than I do I'm unsure what the problem(s) might be. Do you not like:
> - frames in general
> - partial URLs
> - frame busting protection
> - "confusing" users by redirecting
> - using JavaScript in this instance
> - something else

I don't know about the parent poster, but I'd advise against trying to 
restrict the user experience (through javascript). Not only can that 
frustrate the user in using your site -- if I want to open the inner frame 
in a new tab, that's my decision, not yours --, but you cannot really 
control what happens with your content once the user downloads it to their 
computer. You can add a bit of restrictive javascript and stick your head in 
the sand, but a user who wants to can easily circumvent such restrictions.

If you want people to not be able to open the inner frame without the outer 
frame, you'd better look for an alternative solution without separate 
frames. For example, using a template (of the outer frame) wherein the 
contents of the inner frame are placed, will result in web pages where the 
"inner frame"  and "outer frame" aren't separable. (Well, unless the user 
does do so by hand, copying out the html code of the "inner frame" into a 
separate html file; again, you don't have control over your content once it 
is downloaded by the user).

> 
> Andrew Poulos
-- 
Huub de Beer

[toc] | [prev] | [next] | [standalone]


#25598

Fromen2 <nijePravi@mail.com>
Date2014-07-31 08:53 +0200
Message-ID<lrcp62$g1p$1@l01news1.ot.hr>
In reply to#25596
On 07/31/2014 08:26 AM, Huub de Beer wrote:
> Andrew Poulos wrote:
>
>> On 31/07/2014 1:04 AM, Thomas 'PointedEars' Lahn wrote:
>>> Stefan Ram wrote:
>>>
>>>> en2 <nijePravi@mail.com> writes:
>>>>> frameset. So if he makes copy of this link and passes it on new tab
>>>>> like
>>>>
>>>>     Maybe something like:
>>>>
>>>> if( top.location.href.toLowerCase() === "www.example.com/cars.html" )
>>>> top.location.href = "example.com";
>>>>
>>>>     . But this would only work in case that someone had enabled
>>>>     JavaScript.
>>>
>>> Please don't.
>>
>> When I read a response like this from someone who knows far more about
>> coding than I do I'm unsure what the problem(s) might be. Do you not like:
>> - frames in general
>> - partial URLs
>> - frame busting protection
>> - "confusing" users by redirecting
>> - using JavaScript in this instance
>> - something else
>
> I don't know about the parent poster, but I'd advise against trying to
> restrict the user experience (through javascript). Not only can that
> frustrate the user in using your site -- if I want to open the inner frame
> in a new tab, that's my decision, not yours --, but you cannot really
> control what happens with your content once the user downloads it to their
> computer. You can add a bit of restrictive javascript and stick your head in
> the sand, but a user who wants to can easily circumvent such restrictions.
>
> If you want people to not be able to open the inner frame without the outer
> frame, you'd better look for an alternative solution without separate
> frames. For example, using a template (of the outer frame) wherein the
> contents of the inner frame are placed, will result in web pages where the
> "inner frame"  and "outer frame" aren't separable. (Well, unless the user
> does do so by hand, copying out the html code of the "inner frame" into a
> separate html file; again, you don't have control over your content once it
> is downloaded by the user).
>
>>
>> Andrew Poulos
---------------------------------
The problem is quite opposite.
What i want to prevent is that someone comes to the site, chooses one 
sub menu, clicks on copy links location, passes this link over mail to 
some friend, and then when this friend passes this into browser, he will 
get web page outside of frameset.

[toc] | [prev] | [next] | [standalone]


#25603

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2014-07-31 12:46 +0100
Message-ID<0.a61737b51de92bd98b63.20140731124606BST.87tx5x92f5.fsf@bsb.me.uk>
In reply to#25598
en2 <nijePravi@mail.com> writes:
<snip>
> What i want to prevent is that someone comes to the site, chooses one
> sub menu, clicks on copy links location, passes this link over mail to
> some friend, and then when this friend passes this into browser, he
> will get web page outside of frameset.

If you are stuck with frames (and you should give serious thought to
solving the base problem which is that frames break the meaning of
links) there are two things that can help.

First, use some kind of server-side scripting to provide URLs for frame
configurations.  For example, you could decide that

  http://example.com/?cont=cars&menu=vehicles

generates the frame set with the main content frame's src=cars.html and
the navigation frame showing src=vehicles.html.

This will mean that people can quote real URLs "into" your site.  You
can use some of these in the pages themselves in paces where you think
people are most likely to copy links.  (You can even provide a "generate
a link" button, or a "send a link" button, that constructs such a URL
from what the visitor is currently seeing.)

Second, once you have the above in place, use the server's ability to
redirect (or re-write) URLs so that "out of frame" URLs get converted to
one of the above configuration URLs.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#25604

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-07-31 14:56 +0200
Message-ID<1631660.9780uf63I2@PointedEars.de>
In reply to#25603
Ben Bacarisse wrote:

> Second, once you have the above in place, use the server's ability to
> redirect (or re-write) URLs so that "out of frame" URLs get converted to
> one of the above configuration URLs.

Server-side redirection either does not work in this case (the server does 
not "know" *how* a document is displayed), or would just move the problem 
with automatic redirection to the server side.  More later.
 
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#25599

FromJJ <jj4public@vfemail.net>
Date2014-07-31 14:11 +0700
Message-ID<uuwkt3j3ykdu.le65x97ygjib$.dlg@40tude.net>
In reply to#25590
On Wed, 30 Jul 2014 11:05:53 +0200, en2 wrote:
> Hi to all.
> 
> I didn't work with html or javascript for quite sometime and i can not 
> remember how to solve this.
> 
> Basically what i want to do is to block to prevent user on accessing 
> single web page out of the main frame frameset.
> 
> E.g. if the page is www.thePage.com and if the menu link is cars.html
> i want to redirect user to prevent viewing this page outside of 
> frameset. So if he makes copy of this link and passes it on new tab like
> www.thePage/cars.html, he should be redirected to www.thePage.com
> 
> Thnx in advance !

Blocking a page access can only be done from the web server configuration
(e.g.: .htaccess).

With JavaScript, access to a page can only be redirected. The page itself
can still be loaded; and if the client have disabled the JavaScript, the
redirection won't be performed.

A web page can also be configured (via server script) to disallow itself
from being displayed in a frame by adding a specific HTTP response header.
Yet, it won't prevent the page from being loaded from the server. For
example, via non web browser programs such as download managers.

However, if you want to use JavaScript anyway, use this:

if (top && (top.location.hostname !== location.hostname)) {
  location.href = "about:blank";
}

It'll redirect itself to "about:blank" if it's loaded from a frame and the
browser tab's URL doesn't point to the same host name; making the frame
contents blank.

Put it in the page where you want to protect. e.g.: the cars.html.
Put it so that it executes without waiting for the page to finish loading.
Preferably in the HEAD tag, before any other external script and CSS.

[toc] | [prev] | [next] | [standalone]


#25601

Fromen2 <nijePravi@mail.com>
Date2014-07-31 09:50 +0200
Message-ID<lrcsfv$gsk$1@l01news1.ot.hr>
In reply to#25599
On 07/31/2014 09:11 AM, JJ wrote:
> On Wed, 30 Jul 2014 11:05:53 +0200, en2 wrote:
>> Hi to all.
>>
>> I didn't work with html or javascript for quite sometime and i can not
>> remember how to solve this.
>>
>> Basically what i want to do is to block to prevent user on accessing
>> single web page out of the main frame frameset.
>>
>> E.g. if the page is www.thePage.com and if the menu link is cars.html
>> i want to redirect user to prevent viewing this page outside of
>> frameset. So if he makes copy of this link and passes it on new tab like
>> www.thePage/cars.html, he should be redirected to www.thePage.com
>>
>> Thnx in advance !
>
> Blocking a page access can only be done from the web server configuration
> (e.g.: .htaccess).
>
> With JavaScript, access to a page can only be redirected. The page itself
> can still be loaded; and if the client have disabled the JavaScript, the
> redirection won't be performed.
>
> A web page can also be configured (via server script) to disallow itself
> from being displayed in a frame by adding a specific HTTP response header.
> Yet, it won't prevent the page from being loaded from the server. For
> example, via non web browser programs such as download managers.
>
> However, if you want to use JavaScript anyway, use this:
>
> if (top && (top.location.hostname !== location.hostname)) {
>    location.href = "about:blank";
> }
>
> It'll redirect itself to "about:blank" if it's loaded from a frame and the
> browser tab's URL doesn't point to the same host name; making the frame
> contents blank.
>
> Put it in the page where you want to protect. e.g.: the cars.html.
> Put it so that it executes without waiting for the page to finish loading.
> Preferably in the HEAD tag, before any other external script and CSS.
>
-------------------------------
Would it be possible to load this "external page " in frameset ?
E.g. if someone passes www.thePage.com/cars.html
that this page loads in frameset as if he would do this on standard way 
( over submenu ) ?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web