Prevent a webpage being accessed outside a frame.

D

DJ WIce

: Does anyone know how this can be done?


Just give a false doc type.
Or (better) add
<!-- no frame access (just some comment) -->
on the first line of the page and then the doc type on the second line.

Worked in previous times, I'm not sure if it still works.
Wouter
 
R

Randy Webb

DJ said:
: Does anyone know how this can be done?


Just give a false doc type.
Or (better) add
<!-- no frame access (just some comment) -->
on the first line of the page and then the doc type on the second line.

Worked in previous times, I'm not sure if it still works.

How did it prevent a page from being framed? I am curious.
 
D

DJ WIce

: > Just give a false doc type.
: > Or (better) add
: > <!-- no frame access (just some comment) -->
: > on the first line of the page and then the doc type on the second line.
: >
: > Worked in previous times, I'm not sure if it still works.
:
: How did it prevent a page from being framed? I am curious.

:) The question was: "how to prevent webpage being accessed outside a
frame".
So I assumed since this is a javascript group the question was "how can I
prevent the javascript variables on my page to be accessed from an other
frame".

And that's what this does in MSIE lower than 5.5 (not tested above).


Prevent from being framed?
I think it's better to be framed than to be grabed ;-)
So I think it's not smart to make a prevention against framing
(and I think it's against the heart of internet not to allow deeplinking).

Wouter
 
K

kaeli

Does anyone know how this can be done?

Thanks

Sure, if you can guarantee the client has JS enabled.
You can't guarantee that.

But, for most, this works. Change the frame name and index page to
yours.

<script language="javascript" type="text/javascript">
function doLoad()
{
// check that this is in the frameset properly
if (typeof parent.frames['topFrame'] != "object")
{
// reload
top.location.href="index.jsp";
}
}

<body onload="doLoad()">

Also note that my server-side code has variables that indicate which
page was viewed (session variable) and reloads the proper page in the
(dynamic) frameset. If that isn't done, the client will always see the
main page, which sucks for users. You can hack a javascript for that,
too, by passing urls.

--
--
~kaeli~
Kill one man and you are a murderer. Kill millions and you
are a conqueror. Kill everyone and you are God.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top