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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • la_haine

    #1

    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="javas cript" type="text/javascript">
    function bing() {
    if (!top.document. displayView) {
    document.writel n("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'
  • kaeli

    #2
    Re: blocking page views unless viewed in a particular way...

    In article <bnm15p$d9j$11@ athena.ukc.ac.u k>, 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="javas cript" type="text/javascript">
    > function bing() {
    > if (!top.document. displayView) {
    > document.writel n("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.writel n("Sorry, you can't view
    this.");

    -------------------------------------------------
    ~kaeli~
    Jesus saves, Allah protects, and Cthulhu
    thinks you'd make a nice sandwich.


    -------------------------------------------------

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: blocking page views unless viewed in a particular way...

      "la_haine" <p.haine@kent.a c.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="javas cript" type="text/javascript">
      > function bing() {
      > if (!top.document. displayView) {[/color]

      You test for the existence of a property called "displayVie w" 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 != "displayVie w") { ...
      or
      if (!parent.frames["displayVie w"]) { ...
      or
      if (parent.frames["displayVie w"] != window) { ...

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

      At least change the location to something useful!
      location.href = "outOverviewPag eWithProperLink s.html";

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • Vicomte De Valmont

        #4
        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.locatio n==top.location )location.href= "otherfile.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





        "la_haine" <p.haine@kent.a c.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="javas cript" type="text/javascript">
        > function bing() {
        > if (!top.document. displayView) {
        > document.writel n("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]


        Comment

        • la_haine

          #5
          Re: blocking page views unless viewed in a particular way...

          kaeli <infinite.possi bilities@NOSPAM att.net> wrote in
          news:MPG.1a0849 4ad4c1af2898991 4@nntp.lucent.c om:
          [color=blue]
          > try
          > if (top.document == document) document.writel n("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

          Comment

          Working...