SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
-
Jul 16, 2002, 11:31 #1
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'') }
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')"
Big thanks in advanceNew Plastic Arts: Visual Communication | DesignateOnline
Mate went to NY and all he got me was this lousy signature
-
Jul 16, 2002, 13:22 #2
- 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')
-
Jul 16, 2002, 13:48 #3
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 reponseNew Plastic Arts: Visual Communication | DesignateOnline
Mate went to NY and all he got me was this lousy signature
-
Jul 17, 2002, 00:35 #4
- 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 |=---
-
Jul 17, 2002, 01:24 #5
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 careNew Plastic Arts: Visual Communication | DesignateOnline
Mate went to NY and all he got me was this lousy signature
-
Jul 18, 2002, 04:22 #6
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) }
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?
TIANew Plastic Arts: Visual Communication | DesignateOnline
Mate went to NY and all he got me was this lousy signature
-
Jul 18, 2002, 04:29 #7
- 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 |=---
-
Jul 18, 2002, 04:53 #8
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
-
Jul 18, 2002, 05:02 #9
- 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