Submit Your Article Forum Rules

Results 1 to 4 of 4

Thread: browser window control function

Hybrid View

  1. #1
    Member dugfresh33's Avatar
    Join Date
    Jul 2003
    Posts
    88

    browser window control function

    I am trying to create a javascript function that will collect data from text fields in a form on the same page and assign it to variables defined in the function, which will then be used elsewhere in the function to affect the result of user actions.

    Specifically, I want the user to be able to control the size of the browser window by clicking left, right, up, and down arrows. I have accomplished this already by using the following script:

    function resizeMe(deltaX,deltaY) {
    window.resizeBy(deltaX,deltaY);
    }

    and calling the script like this:

    ...

    It works beautifully, but what I would like to do is have the user be able to enter the number of pixels themselves in a simple form, thus being able to control the size more precisely. When the user clicks the "Submit" button, I would like the values entered in the input text fields of the form to be assigned to variables in the function that would then be passed to the "deltaX" and "deltaY" params. When the user then clicks on the right, left, up, or down arrows, the window would resize by the increment defined by "deltaX" and "deltaY".

    Is this too complicated? Can you just set the values of "deltaX" and "deltaY" directly from the form action?

    I'm not sure how feasible this feature would be to implement on a page, whether it would enhance the browsing experience or not, but I'd still like to have the script. It just stems from all of the comments in this forum about how nobody likes having someone else take control of their browser. I thought this might be a nice compromise: the designer who wants artistic control over how the page looks can pop the page open to full screen or whatever when it's loaded, and the user who can't stand having their browser fill their screen can use this feature to control the resize. I realize that not disabling the resize handles would let them do this anyway, but this would just be another way to let the user know that you care about their experience enough to go to the trouble of creating this nice interface for them ;) It basically says you're thinking about them; that you're not too caught up in yourself and your design skills. Just another way to affect your visitors in a subconscious way...
    ...for all have sinned and fall short of the glory of God...
    -- Romans 3:23


    doug sanchez, creative director/lead designer

  2. #2
    Senior Member redcircle's Avatar
    Join Date
    Aug 2003
    Posts
    424
    Code:
    <form>
    <input type="text" name="x" /> X <input type="text" name="y" />
    <input type="button" name="rsize" value="Resize Browser" onclick="resizeTo(x.value, y.value)" />
    </form>
    Note that you actually want to use window.resizeTo(x,y) in your function for it to work. Also note that this function is IE only and is not part of the DOM spec. With the form that I included you do not need to create the resizeMe function. resizeBy() just adds the values given to the existing browser dimensions.
    www.squitosoft.com - PHP development site. featuring Squito Gallery. a php driven photo gallery.
    www.rgfx.net - Specializing in Internet solutions, including Html authoring, Interactive Web sites, 3D/2D Graphics and animation.

  3. #3
    Member dugfresh33's Avatar
    Join Date
    Jul 2003
    Posts
    88

    Thanks, redcircle

    That was very helpful and insightful. I am reminded daily why I am not a programmer. It's not so much being able to do it; it's being able to do it the right way. This, for all intents and purposes, will work just fine. It wasn't exactly what I was asking for, but as I alluded to above, what I was asking for was the equivalent of trying to get to the deli on the east side of the street...by driving west.

    Again, thanks for your help. I wasn't aware that you could use the "form" tag that way. Just out of curiosity, what is the function of the / before the >?
    ...for all have sinned and fall short of the glory of God...
    -- Romans 3:23


    doug sanchez, creative director/lead designer

  4. #4
    WebProWorld MVP ronniethedodger's Avatar
    Join Date
    Aug 2003
    Posts
    1,402

    Re: Thanks, redcircle

    Quote Originally Posted by dugfresh33
    Again, thanks for your help. I wasn't aware that you could use the "form" tag that way. Just out of curiosity, what is the function of the / before the >?
    You use the / on tags that do not require an end tag such as
    and <hr />. The tag starts and ends with itself. Tags such as for bolding require the to tell the browser when to stop rendering bold type.

    It signals to the browser that it does not need to search for the end tag, which speeds up rendering the page (I am guessing it is supposed to). Although it is not required to put the / in at all. But I think it is part of the Html specification to do so.

Similar Threads

  1. toggle function browser compatibility
    By Uncle Dickie in forum Web Programming Discussion Forum
    Replies: 1
    Last Post: 09-03-2007, 10:24 PM
  2. How to control window size - html Q
    By perpetuum-mobile in forum Web Programming Discussion Forum
    Replies: 1
    Last Post: 08-18-2006, 01:49 AM
  3. Shaking the browser window
    By mreif in forum Flash Discussion Forum
    Replies: 1
    Last Post: 08-25-2004, 08:59 AM
  4. Ad-Ware Browser Hijacking is out of Control
    By greeneagle in forum Internet Security Discussion Forum
    Replies: 2
    Last Post: 07-07-2004, 08:48 PM
  5. Disable Right click menu on .swf file in browser window...
    By meenu in forum Flash Discussion Forum
    Replies: 1
    Last Post: 04-29-2004, 10:59 AM

Posting Permissions

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