Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2001
    Posts
    351

    JavaScript question - why doesn't it work??

    Why doesn't this work?

    <script language="JavaScript">
    if(location.href != "top.location.href") {
    location.href = top.location.href;
    }
    </script>

    It works, but it loads and loads forever :p

    thanks,
    - Shawn

  2. #2
    Join Date
    Jun 2000
    Location
    Southern California
    Posts
    12,121
    Are you trying to break out of frames?

    *idiot question*
    HostHideout.com - Where professionals discuss web hosting.

    Chicken

  3. #3
    Join Date
    Mar 2001
    Posts
    351
    Yes! That's exactly right - sorry I didn't make my self clear before. Does anyone know the problem??


    - S

  4. #4
    Code:
    <script language="JavaScript"> 
    if(self.location.href!=top.location.href)
    {
    	top.location.href=self.location.href;
    }
    </script>
    Not sure why your other one would have worked at all. Anyways, this will, put it at the top of your file, in the header, so it checks before the file is loaded.
    ::: Jeremy C. Wright :::
    http://www.ensight.org

  5. #5
    Join Date
    Jul 2001
    Location
    /dev/null
    Posts
    1,219
    Code:
    <script language='javascript'>if(window!=top)top.location.href=location.href;</script>
    Shure that one works.

  6. #6
    Join Date
    Mar 2001
    Posts
    351
    Thanks so much !!

    - S

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •