SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    increasing value of string var

    I am using two variables (myWidth and myHeight) in a popup window script in place of the width and height dimensions so that I can set custom sizes in the specific event.

    I am tweaking the function script to account for a sizing problem in PC/IE5.

    I have this segment...

    if (navigator.appVersion.indexOf("Win") !=-1 && is.ie5) {

    myWidth = "myWidth" + 10
    myHeight = "myHeight" + 29

    }


    I'm new to javascripting by hand and as a result I'm hitting some snags.

    The red code isn't working.
    I know it's wrong, but I can't seem to find info on how it should be done.

    How do I set the script to automatically add 10 and 29 to whatever values are set in the event for myWidth and myHeight so it will automatically create a window 10 pixels wider and 29 pixels higher for PC/IE5 users?

    I can post the entire script if this isn't enough info to understand what I'm after.

    TIA
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  2. #2
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this:

    Code:
    myWidth = (parseInt(myWidth) + 10);
    myHeight = (parseInt(myHeight) + 29);

  3. #3
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How are you initialy setting the two variables? IF you set them like this:
    myWidth=500
    var myHeight=600
    Then you could just do this:
    mywidth=mywidth+20
    myheight=myheight+20
    If not then the previous answer should do.

  4. #4
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thx, makeda I'm sure that would've worked, but I've broken my my script somehow.

    I'm can't be sure whether I broke it or if I only imagined that it was working last night (very late night, came home and *then* started playing around with it.)

    Either way, the original script I was hoping to re-tweak has gone for a burton.
    But, that's ok(ish) because I'm changing tack...

    New popup script, new question...

    This is the script that I'll now be using on any popups on my site...


    function winBRopen(theURL, Name, winW, winH, scroll) { // V 1.0

    var winX = (screen.width - winW) / 2;
    var winY = (screen.height - winH) / 2;

    winProp = 'width='+winW+',height='+winH+',left='+winX+',top='+winY+',scrollbars='+scroll+''

    Win = window.open(theURL, Name, winProp)

    }


    combined with...

    onclick="winBRopen('base.html','viewer','454','516','no')"


    I'm now looking at putting the if/else on with this line...

    winProp = 'width='+winW+',height='+winH+',left='+winX+',top='+winY+',scrollbars='+scroll+''


    Something like...

    if (navigator.appVersion.indexOf("Win") !=-1 && is.ie5) {

    winProp = 'width='+winW++10',height='+winH++29',left='+winX+-5',top='+winY+-15',scrollbars='+scroll+''

    } else {

    winProp = 'width='+winW+',height='+winH+',left='+winX+',top='+winY+',scrollbars='+scroll+''


    The blue text represents where I'm hoping to make the changes and the kind of changes I want to make.
    I'm not overly concerned about having the top and left changed, but if it's simple then I'll do the lot.

    As a newcomer, I'm not even sure if what I'm suggesting is even possible.

    That is why I'm asking here

    So, is that possible? And if so, how exactly should it be written?
    (I'd like to keep it as close to the example as possible, by which I mean, I'd like to keep the changes in the line that I've use above.

    I figure this is a cleaner and more straightforward way of doing it than my previous attempt.

    TIA (again)

    p.s.
    Thx requestcode.

    I was referring to them only as variables in the script. The actual values would only be set in the event.
    e.g. onclick="winBRopen('base.html','viewer','454','516','no')"
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  5. #5
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solution...

    ...

    function winBRopen(theURL, Name, winW, winH, scroll) { // V 1.0

    if (navigator.appVersion.indexOf("Win") !=-1 && is.ie5) {

    winW = (parseInt(winW) + 10)
    winH = (parseInt(winH) + 29)

    }

    var winX = (screen.width - winW) / 2;
    var winY = (screen.height - winH) / 2;

    winProp = 'width='+winW+',height='+winH+',left='+winX+',top='+winY+',scrollbars='+scroll+''

    Win = window.open(theURL, Name, winProp)

    }

    </script>

    </HEAD>
    <BODY>

    <A href="#" onclick="winBRopen('base.html','viewer','454','516','no')" onfocus="blur();">link</a>

    </BODY>
    </HTML>


    This works fine for me (I will have all scrollbars, status bar, resize, etc... turned off by default in all popup windows), but I'd be interested to further find a way that accounted for the size difference regardless of browser chrome.

    Internet Explorer lacks both the innerHeight/Width and outerHeight/Width properties in the window object.
    I'll have to find another way of finding out the dimensions of the chrome on a window.

    Any pointers anyone?
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature


Bookmarks

Posting Permissions

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