Connecting Tech Pros Worldwide Help | Site Map

blocking page views unless viewed in a particular way...

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 20th, 2005, 11:24 AM
la_haine
Guest
 
Posts: n/a
Default blocking page views unless viewed in a particular way...

I have a collection of pages that are designed to be called into an iframe
(named displayView), and the managers don't want people to be able to view
them unless they're in that iframe. If I use the following javascript:

<script language="javascript" type="text/javascript">
function bing() {
if (!top.document.displayView) {
document.writeln("sorry, you can't view this");
}
}
</script>


and use <body onload="bing">, it works in Opera and IE - displays the page
correctly if viewed through the iframe, but says 'sorry, you can't view
this' and nothing else if viewed outside of it. However, in mozilla browsers,
it doesn't work, and I get the error message regardless of how I view the
page.

Can anybody advise me on how to fix this?

--
'Masochists are people that have pleasure confused with pain. In a world that
has television confused with entertainment, doritoes confused with food, and
Dan Quayle confused with a national political leader, masochists are clearly
less mixed-up than the rest of us.'
-P.J.O'Rourke, 'Modern Manners'

  #2  
Old July 20th, 2005, 11:24 AM
kaeli
Guest
 
Posts: n/a
Default Re: blocking page views unless viewed in a particular way...

In article <bnm15p$d9j$11@athena.ukc.ac.uk>, p.haine@kent.ac.uk
enlightened us with...[color=blue]
> I have a collection of pages that are designed to be called into an iframe
> (named displayView), and the managers don't want people to be able to view
> them unless they're in that iframe. If I use the following javascript:
>
> <script language="javascript" type="text/javascript">
> function bing() {
> if (!top.document.displayView) {
> document.writeln("sorry, you can't view this");
> }
> }
> </script>
>
>[/color]

What's the error say?
Is displayView the name of the iframe?

try
if (top.document == document) document.writeln("Sorry, you can't view
this.");

-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
  #3  
Old July 20th, 2005, 11:25 AM
Lasse Reichstein Nielsen
Guest
 
Posts: n/a
Default Re: blocking page views unless viewed in a particular way...

"la_haine" <p.haine@kent.ac.uk> writes:
[color=blue]
> I have a collection of pages that are designed to be called into an iframe
> (named displayView), and the managers don't want people to be able to view
> them unless they're in that iframe.[/color]

I am tempted to not reply, because I think it is a stupid idea to prevent
people from watching pages the way *they* prefer. Allowing the page to load
and then erasing it is *very* rude. So, slap him from me. Anyway ...
[color=blue]
> If I use the following javascript:
>
> <script language="javascript" type="text/javascript">
> function bing() {
> if (!top.document.displayView) {[/color]

You test for the existence of a property called "displayView" in the
top frame's document. I can't see how that is connected to a frame of
that name at all.

Try:
if (window.name != "displayView") { ...
or
if (!parent.frames["displayView"]) { ...
or
if (parent.frames["displayView"] != window) { ...

[color=blue]
> document.writeln("sorry, you can't view this");[/color]

At least change the location to something useful!
location.href = "outOverviewPageWithProperLinks.html";

/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
  #4  
Old July 20th, 2005, 11:25 AM
Vicomte De Valmont
Guest
 
Posts: n/a
Default Re: blocking page views unless viewed in a particular way...

Mah I use it on my website. If a user with js enabled accesses a page
without passing from the front page 8that is, outside a global frameset, for
the index page of the site _is_ a frameset file), I set up a few tricks to
let him/her see the desired page but firstly dashing through the main page,
so reinstating it within the frameset: but maybe for an iframe you don't
truly need a frameset, it might suffice that in your file you check whether
self.location==top.location.
If that is the case, you redirect to the other page which includes the
iframe document.

That is, put this command in your iframe meant file:

if(self.location==top.location)location.href="othe rfile.html";

Assuming otherfile.html is the file which includes the iframe.

it could be either simple like that, or you may append a ?plusData to the
url if you need to pass parameters emulating sort of a 'get' method in a
form..
ciao
Alberto vallini
http://www.unitedscripters.com/




"la_haine" <p.haine@kent.ac.uk> ha scritto nel messaggio
news:bnm15p$d9j$11@athena.ukc.ac.uk...[color=blue]
> I have a collection of pages that are designed to be called into an iframe
> (named displayView), and the managers don't want people to be able to view
> them unless they're in that iframe. If I use the following javascript:
>
> <script language="javascript" type="text/javascript">
> function bing() {
> if (!top.document.displayView) {
> document.writeln("sorry, you can't view this");
> }
> }
> </script>
>
>
> and use <body onload="bing">, it works in Opera and IE - displays the page
> correctly if viewed through the iframe, but says 'sorry, you can't view
> this' and nothing else if viewed outside of it. However, in mozilla[/color]
browsers,[color=blue]
> it doesn't work, and I get the error message regardless of how I view the
> page.
>
> Can anybody advise me on how to fix this?
>
> --
> 'Masochists are people that have pleasure confused with pain. In a world[/color]
that[color=blue]
> has television confused with entertainment, doritoes confused with food, a[/color]
nd[color=blue]
> Dan Quayle confused with a national political leader, masochists are[/color]
clearly[color=blue]
> less mixed-up than the rest of us.'
> -P.J.O'Rourke, 'Modern Manners'[/color]


  #5  
Old July 20th, 2005, 11:26 AM
la_haine
Guest
 
Posts: n/a
Default Re: blocking page views unless viewed in a particular way...

kaeli <infinite.possibilities@NOSPAMatt.net> wrote in
news:MPG.1a08494ad4c1af28989914@nntp.lucent.com:
[color=blue]
> try
> if (top.document == document) document.writeln("Sorry, you can't view
> this.");[/color]

that did the job - thanks :)

--
We generally describe the most repulsive examples of humanity's cruelty as
brutal or bestial, implying by these adjectives that such behaviour is
characteristic of less highly developed animals such as ourselves. In truth,
however, the extremes of 'brutal' behaviour are confined to humanity; and
there is no parallel in nature to our savage treatment of each other.
- Storr, 1968
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.