top.location.href question

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

    top.location.href question



    I'm very new to javascript and need only a small amount in an asp.net
    application I'm working on. I apologize if I'm not using the correct
    terminology to describe the problem.
    I got the code below to work under most conditions to capture the client's
    screen resolution and then redirect to another page (but there likely are
    better ways to code this). This needs to work under 3 conditions; A) if the
    current top.location.hr ef is similar to www.hhh/ B) if the current
    top.location.hr ef is similar to www.hhh/?user=xxx and C) if the current
    top.location.hr ef is similar to www.hhh/default.apsx

    The code below works for situation A and B, but not C. In other words, I
    need to redirect to

    and not to www.hhh/default.aspxPrelim/00bPreliminary.aspx

    (while also passing the screen resolution and username if there is one).
    Can someone please show me what I'm missing to get rid of the default.aspx
    if it is there, or to write this in a better manner?

    <script type = "text/javascript" >
    <!--
    {
    res = "res="+screen.w idth+"x"+screen .height;
    y = top.location.pa thname ;
    a = location.search ;
    if (a == ""){
    a = "?";
    }
    top.location.hr ef= y+"Prelim/00bPreliminary. aspx"+a+"&"+res ;
    }
    // -->
    </script>

    Thanks
    Jeff


    --
    Posted via a free Usenet account from http://www.teranews.com

  • Randy Webb

    #2
    Re: top.location.hr ef question

    Jeff said the following on 12/24/2006 10:57 AM:
    >
    >
    I'm very new to javascript and need only a small amount in an asp.net
    application I'm working on. I apologize if I'm not using the correct
    terminology to describe the problem.
    I got the code below to work under most conditions to capture the
    client's screen resolution and then redirect to another page (but there
    likely are better ways to code this).
    Why is the resolution even important? Unless you intend to resize the
    window itself I have never understood it's importance unless the
    resulting page deals with desktop items or the such.

    This needs to work under 3 conditions;
    A) if the current top.location.hr ef is similar to www.hhh/
    B) if the current top.location.hr ef is similar to www.hhh/?user=xxx and
    C) if the current top.location.hr ef is similar to www.hhh/default.apsx
    It almost seems pedantic, but you have to define "is similar".
    The code below works for situation A and B, but not C. In other words, I
    need to redirect to

    and not to www.hhh/default.aspxPrelim/00bPreliminary.aspx
    What would be the initial URL that you need to redirect from? Without
    knowing that, a person can only guess as to how to fix the code.
    (while also passing the screen resolution and username if there is one).
    Can someone please show me what I'm missing to get rid of the
    default.aspx if it is there, or to write this in a better manner?
    y = top.location.pa thname.replace( 'default.aspx', '')

    Will remove default.aspx from the location, which is what you are saying
    you want to do.
    <script type = "text/javascript" >
    <!--
    {
    res = "res="+screen.w idth+"x"+screen .height;
    y = top.location.pa thname ;
    It may, or may not, be possible in your application but beware that
    top.location.pa thname will give erroneous results if your page gets
    "framed". document.locati on.pathname is a safer route, then set
    top.location.hr ef and it will bust out of any potential framed situations.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

    Comment

    • Jeff

      #3
      Re: top.location.hr ef question


      "Randy Webb" <HikksNotAtHome @aol.comwrote in message
      news:rPGdnSIVOY 6dehPY4p2dnA@te lcove.net...
      Jeff said the following on 12/24/2006 10:57 AM:
      Why is the resolution even important? Unless you intend to resize the
      window itself I have never understood it's importance unless the resulting
      page deals with desktop items or the such.
      It is a somewhat specialized application that isn't really intended to pubic
      use.
      The application really needs everything to show without scroll bars. In the
      unlikely event that someone is using a monitor smaller than 800x600 I need
      to provide a warning that the application won't work properly.
      y = top.location.pa thname.replace( 'default.aspx', '')
      >
      Will remove default.aspx from the location, which is what you are saying
      you want to do.
      The code above (with the .replace) works for me.

      Thanks.

      Jeff


      --
      Posted via a free Usenet account from http://www.teranews.com

      Comment

      Working...