473,396 Members | 2,111 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,396 software developers and data experts.

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'
Jul 20 '05 #1
4 1701
In article <bn***********@athena.ukc.ac.uk>, p.*****@kent.ac.uk
enlightened us with...
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>


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
-------------------------------------------------
Jul 20 '05 #2
"la_haine" <p.*****@kent.ac.uk> writes:
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.
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 ...
If I use the following javascript:

<script language="javascript" type="text/javascript">
function bing() {
if (!top.document.displayView) {
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) { ...

document.writeln("sorry, you can't view this");


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

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
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.*****@kent.ac.uk> ha scritto nel messaggio
news:bn***********@athena.ukc.ac.uk...
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, a nd 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'

Jul 20 '05 #4
kaeli <in********************@NOSPAMatt.net> wrote in
news:MP************************@nntp.lucent.com:
try
if (top.document == document) document.writeln("Sorry, you can't view
this.");


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
Jul 20 '05 #5

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

Similar topics

4
by: Jonathan Fine | last post by:
Hello I have written a program that interacts with a command line program. Roughly speaking, it mimics human interaction. (With more speed and accuracy, less intelligence.) It works fine...
23
by: David McCulloch | last post by:
QUESTION-1: How can I detect if Norton Internet Security is blocking pop-ups? QUESTION-2a: How could I know if a particular JavaScript function has been declared? QUESTION-2b: How could I...
7
by: Michi Henning | last post by:
Hi, I'm using a non-blocking connect to connect to a server. Works fine -- the server gets and accepts the connection. However, once the connection is established, I cannot retrieve either the...
12
by: Veeresh | last post by:
In my asp.net application I want to block mouse right click on my web pages. That means instead of popup menu I may just display some message or no message at all. Hot to do that? Thanks, Veer
4
by: Guadala Harry | last post by:
Just wondering what could cause this: I have observed that when first opening an aspx page, the Page_Load event fires as expected. Then I go to other pages in the site. When returning to any page...
1
by: loosecannon_1 | last post by:
Hello everyone, I am hoping someone can help me with this problem. I will say up front that I am not a SQL Server DBA, I am a developer. I have an application that sends about 25 simultaneous...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
4
by: Steve | last post by:
I thought that this was available for all elements in Firefox, but recently had a page where a div didn't have it. I put in an id style for it, thinking that would do the trick, but it didn't. ...
9
by: Denis | last post by:
Hello, Maybe somebody already solved this task. I need to load JS asynchronously without blocking browser. This means that I do not need to block browser to load/render during loading script. The...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.