Using / passing a variable - n00b question :)

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

    #1

    Using / passing a variable - n00b question :)

    I am creating an initial index.htm page on which I show some disclaimers and
    introduction information.

    In the head section I have Javascript which determines the screen resolution of
    the client. I assign values to two variables to assign the width and height.
    (my_width and my_height).

    I have a Form button which is clicked on agreeing to the disclaimers. On
    clicking the form button I want to direct the user (open a new window) to a
    specific URL (sub-directory) in which I have specific files for use with a
    screen resolution.

    The form button works OK with the following in the <body> :

    </div>
    <FORM>
    <div align="center">
    <input name="Agree" type="button" id="Continue" onFocus="this.b lur()"
    onClick="NewWin dow('640x480/redirect.htm',' New','640','480 ','no','center' );return
    false" value="I Agree">
    </div>
    </FORM></td>

    How do I use the variables my_width and my_height to automatically load the
    appropriate redirect.htm in the correct direct name ('640x480' or '800x600'
    etc)?

    Thanks.

    Mal


    Remove x- for correct email addy
  • Mal Ice

    #2
    Re: Using / passing a variable - n00b question :)

    On Sat, 28 Aug 2004 15:40:57 +0100, Mal Ice <spam@tembograp hics-x.com> wrotf:

    I forgot to add that I have a user created function called NewWindow...

    var win=null;
    function NewWindow(mypag e,myname,w,h,sc roll,pos){
    if(pos=="random "){LeftPosition =(screen.width) ?Math.floor(Mat h.random()*(scr een.width-w)):100;TopPosi tion=(screen.he ight)?Math.floo r(Math.random() *((screen.heigh t-h)-75)):100;}
    if(pos=="center "){LeftPosition =(screen.width) ?(screen.width-w)/2:100;TopPositi on=(screen.heig ht)?(screen.hei ght-h)/2:100;}
    else if((pos!="cente r" && pos!="random") ||
    pos==null){Left Position=0;TopP osition=20}
    settings='width ='+w+',height=' +h+',top='+TopP osition+',left= '+LeftPosition+ ',scrollbars='+ scroll+',locati on=no,directori es=no,status=no ,menubar=no,too lbar=no,resizab le=no';
    win=window.open (mypage,myname, settings);}

    I suppose this has an impact on how my_width and my_height get used in the
    "onClick" instructions to run the NewWindow function.

    Mal



    Remove x- for correct email addy

    Comment

    • Randy Webb

      #3
      Re: Using / passing a variable - n00b question :)

      Mal Ice wrote:[color=blue]
      > I am creating an initial index.htm page on which I show some disclaimers and
      > introduction information.
      >
      > In the head section I have Javascript which determines the screen resolution of
      > the client. I assign values to two variables to assign the width and height.
      > (my_width and my_height).
      >
      > I have a Form button which is clicked on agreeing to the disclaimers. On
      > clicking the form button I want to direct the user (open a new window) to a
      > specific URL (sub-directory) in which I have specific files for use with a
      > screen resolution.[/color]

      You can stop right there. Screen resolution has nothing to do with
      browser size. My desktop is 2048 pixels wide, and 768 pixels high. But
      my browser window is smaller than 800x600, so which page should I get?




      --
      Randy
      comp.lang.javas cript FAQ - http://jibbering.com/faq

      Comment

      • Mal Ice

        #4
        Re: Using / passing a variable - n00b question :)

        On Sat, 28 Aug 2004 11:54:45 -0400, Randy Webb <HikksNotAtHome @aol.com> wrotf:
        [color=blue]
        >Mal Ice wrote:[color=green]
        >> I am creating an initial index.htm page on which I show some disclaimers and
        >> introduction information.
        >>
        >> In the head section I have Javascript which determines the screen resolution of
        >> the client. I assign values to two variables to assign the width and height.
        >> (my_width and my_height).
        >>
        >> I have a Form button which is clicked on agreeing to the disclaimers. On
        >> clicking the form button I want to direct the user (open a new window) to a
        >> specific URL (sub-directory) in which I have specific files for use with a
        >> screen resolution.[/color]
        >
        >You can stop right there. Screen resolution has nothing to do with
        >browser size. My desktop is 2048 pixels wide, and 768 pixels high. But
        >my browser window is smaller than 800x600, so which page should I get?
        >
        >http://allmyfaqs.com/faq.pl?AnySizeDesign[/color]

        I am not concerned about the size of the browser window that opens my initial
        page, I want to control the size of the browser on clicking a button. I'll
        check the screen size (not browser size) and then determine what URL I will use
        on a button click

        if (screen.width== 640||screen.hei ght==480) //if 640x480
        var screen2="640x48 0/redirect.htm",m y_width ="640",my_heigh t ="480"


        else if (screen.width== 800||screen.hei ght==600) //if 800x600
        var screen2="800x60 0/redirect.htm",m y_width ="800",my_heigh t ="600"

        else if (screen.width== 1024||screen.he ight==768) //if 1024x768
        var screen2="1024x7 68/redirect.htm",m y_width ="1024",my_heig ht ="768"

        else //if all else
        var screen2="1024x7 68/redirect.htm",m y_width ="1024",my_heig ht ="768"


        I will open the URL with a specified browser size (using variables) that relates
        to the screen width and height that will maximise screen collateral to display
        images.

        Does this make sense?

        TIA

        Mal


        Remove x- for correct email addy

        Comment

        • Andrew Thompson

          #5
          Re: Using / passing a variable - n00b question :)

          On Sat, 28 Aug 2004 17:49:51 +0100, Mal Ice wrote:
          [color=blue]
          > I am not concerned about the size of the browser window that opens my initial
          > page, I want to control the size of the browser on clicking a button. I'll
          > check the screen size (not browser size) and then determine what URL I will use
          > on a button click[/color]

          'I', four times in that sentence.

          What will your *users* want?

          [ Most users prefer a page that adjusts to
          'any-damn size' they choose at that instant. ]

          --
          Andrew Thompson
          http://www.PhySci.org/ Open-source software suite
          http://www.PhySci.org/codes/ Web & IT Help
          http://www.1point1C.org/ Science & Technology

          Comment

          • Andrew Thompson

            #6
            Re: Using / passing a variable - n00b question :)

            On Sun, 29 Aug 2004 04:28:19 GMT, Andrew Thompson wrote:
            [color=blue]
            > 'I', four times in that sentence.[/color]

            OK ..paragraph. [ ;-) ]

            --
            Andrew Thompson
            http://www.PhySci.org/ Open-source software suite
            http://www.PhySci.org/codes/ Web & IT Help
            http://www.1point1C.org/ Science & Technology

            Comment

            • Randy Webb

              #7
              Re: Using / passing a variable - n00b question :)

              Mal Ice wrote:[color=blue]
              > On Sat, 28 Aug 2004 11:54:45 -0400, Randy Webb <HikksNotAtHome @aol.com> wrotf:
              >
              >[color=green]
              >>Mal Ice wrote:
              >>[color=darkred]
              >>>I am creating an initial index.htm page on which I show some disclaimers and
              >>>introducti on information.
              >>>
              >>>In the head section I have Javascript which determines the screen resolution of
              >>>the client. I assign values to two variables to assign the width and height.
              >>>(my_width and my_height).
              >>>
              >>>I have a Form button which is clicked on agreeing to the disclaimers. On
              >>>clicking the form button I want to direct the user (open a new window) to a
              >>>specific URL (sub-directory) in which I have specific files for use with a
              >>>screen resolution.[/color]
              >>
              >>You can stop right there. Screen resolution has nothing to do with
              >>browser size. My desktop is 2048 pixels wide, and 768 pixels high. But
              >>my browser window is smaller than 800x600, so which page should I get?
              >>
              >>http://allmyfaqs.com/faq.pl?AnySizeDesign[/color]
              >
              >
              > I am not concerned about the size of the browser window that opens my initial
              > page, I want to control the size of the browser on clicking a button. I'll
              > check the screen size (not browser size) and then determine what URL I will use
              > on a button click[/color]

              No, you will *attempt* to open a window that you (incorrectly) *think*
              is the right size and resolution. Had you bothered to read the article I
              referenced, you might understand that. So, let me say it simply. This
              is MY browser. Leave it the @#$@ alone as far as resizing, removing
              chrome or any other thing you *think* you can accomplish. Before you get
              annoyed, let me explain it. I use norton. It has this neat little
              section of script it inserts in all pages, that disables the window.open
              call. I also have window resizing disabled. So, how do you intend to
              *attempt* to open a window a certain size? And I am not the only person
              on the web that uses popup blocking software.
              [color=blue]
              > if (screen.width== 640||screen.hei ght==480) //if 640x480[/color]

              Thats a dubious test. If the screen width is 640, 100-1 the height is
              480 and vice versa. No need to test for one or the other.
              [color=blue]
              > var screen2="640x48 0/redirect.htm",m y_width ="640",my_heigh t ="480"
              >
              >
              > else if (screen.width== 800||screen.hei ght==600) //if 800x600
              > var screen2="800x60 0/redirect.htm",m y_width ="800",my_heigh t ="600"[/color]

              Same as above.
              [color=blue]
              > else if (screen.width== 1024||screen.he ight==768) //if 1024x768
              > var screen2="1024x7 68/redirect.htm",m y_width ="1024",my_heig ht ="768"[/color]

              Same as above.
              [color=blue]
              > else //if all else
              > var screen2="1024x7 68/redirect.htm",m y_width ="1024",my_heig ht ="768"[/color]

              So, thats where I would fall in. Or rather, where you *think* I should
              fall in. What makes you think you are the one to decide what size to
              make *my* browser window? Its mine, leave it the !@#! alone.
              [color=blue]
              >
              > I will open the URL with a specified browser size (using variables) that relates
              > to the screen width and height that will maximise screen collateral to display
              > images.[/color]

              See above. Give me an image, let *me* decide what size I want my window,
              because in the end, I *will* be the one to decide.
              [color=blue]
              > Does this make sense?[/color]

              About as much sense as attempting to kiss a wildcat after sandpapering
              its ass.
              [color=blue]
              > TIA[/color]

              Welcome.

              --
              Randy
              comp.lang.javas cript FAQ - http://jibbering.com/faq

              Comment

              • Robert

                #8
                Re: Using / passing a variable - n00b question :)

                In article <ei51j0hptec2m5 3neoiqj464j5u5b vu6oo@4ax.com>,
                Mal Ice <spam@tembograp hics-x.com> wrote:
                [color=blue]
                > I am creating an initial index.htm page on which I show some disclaimers and
                > introduction information.[/color]

                Folks are assuming you are writing for the internet here. The answers
                may be different if your were writing for a company intranet.

                Are you planning on pestering me every time I enter your site with these
                questions? Why should I enter your site?
                [color=blue]
                > I have a Form button which is clicked on agreeing to the disclaimers. On
                > clicking the form button I want to direct the user (open a new window) to a
                > specific URL (sub-directory) in which I have specific files for use with a
                > screen resolution.
                >[/color]

                Why don't you simplify you design by using the existing window? If I
                want a new window, I could do a right click and select display the link
                in a new window before I got to your site. I think it will be faster
                for me to drag the window to a larger size the learning a unique user
                interface for your site. Think how yahoo, ebay, and amazon act.

                Any reason why you are not?

                I think most internet user are a rather impatient lot. Why are you
                slowing them down?

                Maybe you are doing some copyright or bank verification task and you
                need need to do this.

                If

                Comment

                • Mal Ice

                  #9
                  Re: Using / passing a variable - n00b question :)

                  On Mon, 30 Aug 2004 02:38:53 GMT, Robert <rccharles@my-deja.com> wrotf:
                  [color=blue]
                  >In article <ei51j0hptec2m5 3neoiqj464j5u5b vu6oo@4ax.com>,
                  > Mal Ice <spam@tembograp hics-x.com> wrote:
                  >[color=green]
                  >> I am creating an initial index.htm page on which I show some disclaimers and
                  >> introduction information.[/color]
                  >
                  >Folks are assuming you are writing for the internet here. The answers
                  >may be different if your were writing for a company intranet.[/color]
                  Neither. A bit of self promotion on a business card-sized cd. Browsers are the
                  most ubiquitous display mechanisms on both PC and Mac. I wanted something cross
                  platform.[color=blue]
                  >
                  >Are you planning on pestering me every time I enter your site with these
                  >questions? Why should I enter your site?[/color]
                  It isn't a "site". As the material I am presenting is copyright (art images) I
                  want to get them to positively acknowledge that fact. They will do this just
                  once. Either I will be contacted about doing some work for them or my $0.80
                  "eCard" will be in the bin. This is likely to be a "single hit" project. So no
                  "pestering" on my behalf.[color=blue]
                  >[color=green]
                  >> I have a Form button which is clicked on agreeing to the disclaimers. On
                  >> clicking the form button I want to direct the user (open a new window) to a
                  >> specific URL (sub-directory) in which I have specific files for use with a
                  >> screen resolution.
                  >>[/color]
                  >
                  >Why don't you simplify you design by using the existing window? If I
                  >want a new window, I could do a right click and select display the link[/color]
                  Not with a javascript to prevent a right click you cant.[color=blue]
                  >in a new window before I got to your site. I think it will be faster
                  >for me to drag the window to a larger size the learning a unique user
                  >interface for your site. Think how yahoo, ebay, and amazon act.[/color]
                  A single click of a single button which says "Continue" is hardly a learning
                  experience![color=blue]
                  >
                  >Any reason why you are not?[/color]

                  I do not know of any other way of getting the client browser not to display the
                  tool bar, links, scroll bars etc. WITHOT having to open another window. I want
                  to have a "clean" interface (top title and bottom status bar only) filling the
                  client screen size. A "Chromeless " pop-up window apparently is not supported
                  under XP SP1, and pop-ups are hit and miss if browsers are blocking them.
                  Opening a new window may be the both the best and easiest option to get my clean
                  interface with minimal user input other than putting an autorun cd in their PC
                  or MAC and clicking a single button.[color=blue]
                  >
                  >I think most internet user are a rather impatient lot. Why are you
                  >slowing them down?[/color]
                  To the contrary me thinks.[color=blue]
                  >
                  >Maybe you are doing some copyright or bank verification task and you
                  >need need to do this.[/color]
                  Yup.[color=blue]
                  >
                  >If[/color]
                  Thanks for listening.

                  Mal


                  Remove x- for correct email addy

                  Comment

                  • Mal Ice

                    #10
                    Re: Using / passing a variable - n00b question :)

                    On Sat, 28 Aug 2004 15:40:57 +0100, Mal Ice <spam@tembograp hics-x.com> wrotf:

                    [color=blue]
                    >
                    ></div>
                    ><FORM>
                    ><div align="center">
                    ><input name="Agree" type="button" id="Continue" onFocus="this.b lur()"
                    >onClick="NewWi ndow('640x480/redirect.htm',' New','640','480 ','no','center' );return
                    >false" value="I Agree">
                    ></div>
                    ></FORM></td>
                    >
                    >How do I use the variables my_width and my_height to automatically load the
                    >appropriate redirect.htm in the correct direct name ('640x480' or '800x600'
                    >etc)?
                    >
                    >
                    >[/color]
                    To answer my own question....

                    I need to use the variables in the following format:

                    '+my_width+'

                    I cannot just use the variable in this way:

                    'my_width'.

                    Simple when you know how. And I didn't until I had to look at the sources of a
                    few javascripts on the net (Dynamic Drive to be precise!).

                    Mal



                    Remove x- for correct email addy

                    Comment

                    • Robert

                      #11
                      Re: Using / passing a variable - n00b question :)

                      Mal Ice <spam@tembograp hics-x.com> wrote in message[color=blue]
                      > Neither. A bit of self promotion on a business card-sized cd.
                      > Browsers are the most ubiquitous display mechanisms on both PC and Mac.
                      > I wanted something cross platform.[/color]

                      Seems like good application to me.

                      People were thinking that you were writing an Internet application.
                      The eCard is a different situation.

                      I would still recommend that you let the user resize the window and
                      have scroll bars. The user may want to have your eCard on the screen
                      and look at some other application on the computer. Like update their
                      address book. It would be a pain to have to copy down you phone
                      number on a piece of paper.
                      [color=blue]
                      > interface with minimal user input other than putting an autorun cd in their PC
                      > or MAC and clicking a single button.[/color]

                      I do not know how, but I suspect you could get invoke IE on your page
                      through an autorun file. I looked in an autorun file once and you
                      could see were an exe file was invoked.

                      Good luck with you eCard.

                      Robert

                      Comment

                      • Thomas 'PointedEars' Lahn

                        #12
                        Re: Using / passing a variable - n00b question :)

                        Mal Ice wrote:
                        [color=blue]
                        > I am creating an initial index.htm page on which I show some disclaimers
                        > and introduction information.
                        >
                        > In the head section I have Javascript which determines the screen
                        > resolution of the client.[/color]

                        It is impossible to do that. And even if you could, it would be not of much
                        use to you:

                        Display resolution != desktop size != browser window size != viewport size.
                        [psf 3.7]
                        [color=blue]
                        > I assign values to two variables to assign the width and
                        > height. (my_width and my_height).[/color]

                        <http://www.geocities.c om/peace_cake.geo/img/fullscreen.htm>
                        (Courtesy of Steffen Laubner)
                        [color=blue]
                        > I have a Form button which is clicked on agreeing to the disclaimers.[/color]

                        You don't really need disclaimers on Web sites.
                        [color=blue]
                        > On clicking the form button I want to direct the user (open a new window)
                        > to a specific URL (sub-directory) in which I have specific files for use
                        > with a screen resolution.
                        >
                        > The form button works OK with the following in the <body> :
                        >
                        > </div>[/color]

                        Where is the corresponding <div>?
                        [color=blue]
                        > <FORM>[/color]

                        This is invalid HTML. An "action" attribute value is required.

                        <http://validator.w3.or g/>
                        [color=blue]
                        > <div align="center">[/color]

                        The "align" attribute is deprecated in favor of CSS and may be used with
                        Transitional DTDs only.

                        <div style="margin-left:auto; margin-right:auto;">.. .</div>
                        [color=blue]
                        > <input name="Agree" type="button" id="Continue" onFocus="this.b lur()"[/color]

                        Your "onFocus" attribute value prevents keyboard navigation to this button
                        which is a Bad Thing, even on an intranet.
                        [color=blue]
                        > onClick="NewWin dow('640x480/redirect.htm',' New','640','480 ','no',
                        > 'center');retur n false"[/color]

                        Since this is not a visual hyperlink, it is not required to cancel the
                        "click" event. Remove ";return false".
                        [color=blue]
                        > value="I Agree">[/color]

                        Without support for client-side scripting, users will not be able to
                        use that button, too. Use a submit button (input[type="submit"]) and
                        perhaps a server-side application.
                        [color=blue]
                        > </div>
                        > </FORM></td>[/color]

                        The "form" element should be parent of the table if the table contains
                        tabular information. If it does not, you should use CSS instead.
                        [color=blue]
                        > How do I use the variables my_width and my_height to automatically load
                        > the appropriate redirect.htm in the correct direct name ('640x480' or
                        > '800x600' etc)?[/color]

                        Do you mean _directory_ name? (JFYI: It is not really a directory but
                        a URI path component.)

                        NewWindow(my_wi dth + 'x' + my_height + '/redirect.htm');

                        But as I already pointed out, optimization for a certain resolution is
                        utter nonsense, and so using the above line is.
                        [color=blue]
                        > Remove x- for correct email addy[/color]

                        No, I won't. Instead, you will either stop spoiling the global second-level
                        domain namespace and change your From header to something appropriate, i.e.
                        something that applies to Internet/ Usenet standards (RFC 2822 says: "A
                        mailbox receives mail"; RFC 1036 specifies the From header to contain an
                        address in the Internet format), to the Netiquette (RFC 1855) and last but
                        not least to the Acceptable Use Policy of your service provider[1], or
                        consider yourself killfiled globally as well as a formal complaint sent to
                        your SP (Nildram Ltd.) which may cause restriction or cancellation of your
                        access to the service. You have been warned.

                        <http://www.interhack.n et/pubs/munging-harmful/>


                        PointedEars
                        ___________
                        [1] <http://www.nildram.net/pdf/Naup0904.pdf>, page 2

                        Comment

                        • Dr John Stockton

                          #13
                          Re: Using / passing a variable - n00b question :)

                          JRS: In article <1649003.1l1fA6 tUyK@PointedEar s.de>, dated Sat, 4 Sep
                          2004 13:31:52, seen in news:comp.lang. javascript, Thomas 'PointedEars'
                          Lahn <PointedEars@we b.de> posted :[color=blue]
                          >[color=green]
                          >> Remove x- for correct email addy[/color]
                          >
                          >No, I won't. Instead, you will either stop spoiling the global second-level
                          >domain namespace and change your From header to something appropriate, i.e.
                          >something that applies to Internet/ Usenet standards (RFC 2822 says: "A
                          >mailbox receives mail"; RFC 1036 specifies the From header to contain an
                          >address in the Internet format), to the Netiquette (RFC 1855) and last but
                          >not least to the Acceptable Use Policy of your service provider[1], or
                          >consider yourself killfiled globally as well as a formal complaint sent to
                          >your SP (Nildram Ltd.) which may cause restriction or cancellation of your
                          >access to the service. You have been warned.[/color]


                          Ignore him; he's trying to start the Fourth Reich single-handedly.

                          He's also a hypocrite, as he disdains to comply accurately with the
                          accepted standards in his own postings. Whether he understands why is
                          not important.

                          Heil Thomas!

                          --
                          © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
                          Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms, & links.
                          Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
                          Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)

                          Comment

                          Working...