SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  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)

    Unhappy quick fix needed on (simple?) popup script

    I'm trying to put together a simple popup window script that has everything apart from the url preset in the function itself.
    The url will be set in the inline function call.

    Hopefully by looking at where I'm at now, you'll see what I mean...

    Code:
    function menuPop(url) {	
    
    winW = (screen.width / 2);
    winH = (screen.height);
    
    window.open(url, mainWin, 'width='+winW+',height='+winH+',left=0,top=0,resize='1'')
    }
    The target/window name will always be called mainWin.
    This is so it will put the destination url in the main window (mainWin) if it exists, but will create it if mainWin doesn't exist.

    The window position will always be 0,0

    The width will be 50% of the available screenwidth.
    The height will be 100% of the available screenheight.

    The only window feature that should be on is the resize.


    I'm trying to build it so that the inline footprint is as small as possible...

    Code:
    onclick="menuPop('page1.html')"
    I'm obviously not seeing something really obvious, but I've gone screen-crazy and I can't see what's wrong so can't get it fixed.

    Big thanks in advance
    New Plastic Arts: Visual Communication | DesignateOnline

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

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You just need to change the last line of your function.

    var mainWin=window.open(url, mainWin, 'width='+winW+',height='+winH+',left=0,top=0,resize=1')

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

    I actually fixed it myself after a short break away from the screen for a while.
    I should've posted it sooner.

    I saw what the problem was. Guess I'd just been staring at it too long and my brain had fried.

    But still, thx alot for the reponse
    New Plastic Arts: Visual Communication | DesignateOnline

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

  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    shouldn't mainWin be 'mainWin'

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  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)
    Yes, it should've been and after a short break I saw it and corrected it.

    It now works fine and dandy


    But thx, Flawless. It's nice to know that you care
    New Plastic Arts: Visual Communication | DesignateOnline

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

  6. #6
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, slightly different requirements, slightly different problem...

    Trying to create a square popup window that is sized and positioned relative to the screensize (specifically the screen height).

    Code:
    function winPop(url) {
    var	winW = screen.width * 0.4
    
    var	winY = (screen.height - winW)	/ 2
    var winX = (screen.width - winW)	/ 2
    
    winProp = 'width='+winW+',height='+winW+',left='+winX+',top='+winY+',scrollbars=no'
    Win = window.open(url, 'myMainWindow', winProp)
    }
    This works fine for sizes up to * 0.4

    Anything larger than 0.4 and the proportions begin to widen (losing its square ratio) and the window position begins to move up the screen (losing its vertical centering).

    Anyone point out to me why this is happening and how the script should be written to prevent it?

    TIA
    New Plastic Arts: Visual Communication | DesignateOnline

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

  7. #7
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Surely it will - don't you really want:

    winY = (screen.height / 2) - (winW / 2);

    As for disproportional size when both width and height are
    the same ... umm - i'm at a loss!

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  8. #8
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Once again, after a wee break, i spotted that I'd used screen.width for the winW variable and not screen.height.
    I had intended it to be screen.height.

    I'm not altogether sure why this has an effect on the window height:width ratio, but it appears that it does.

    Swapping it over seems to have been enough to fix both problems.

    But once again, again, again, Flawless, thx for the heads up

    <edit>
    I just tried using your fix and it seemed to sort out the position, but had no impact on the ratio problem.

    I stuck with simply swapping the screen.width for screen.height
    </edit>
    New Plastic Arts: Visual Communication | DesignateOnline

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

  9. #9
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds good to me.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •