|
-
Jul 16th, 2004, 02:52 PM
#1
JavaScript: Position popup window
I want to position a popup window in the center of the browser
window not the center of the screen. This is what I am using to
open the window and the left property works and the top
property doesn't for centering in the screen. So how do I get it to
center in the browser window and if not, how to get the top
property to center correctly?
Code:
function Zoom(imgName,imgWidth,imgHeight,oPosL,oPosT) {
//Center window from center of screen
//oPosL and oPosT are center of screen - (screen.width/2) etc.
var TempLeft = (imgWidth / 2);
var TempTop = (imgHeight / 2);
var PosL = (oPosL - TempLeft);
var PosT = (oPosT - TempTop);
zoomWindow = window.open '', 'zoomWin', 'width='+imgWidth+',height='+imgHeight
+'top='+PosT+',left='+PosL+',toolbar=0,menubar=0,location=0,scrollbars=0')
zoomWindow.window.resizeTo(imgWidth, imgHeight+30);
}
Thanks for any assistance.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 16th, 2004, 03:05 PM
#2
!@#$!@$, I was missing a @#*$! comma.
So it now centers in the screen, but can we get it to center in the
browser (in case the user is not running the browser in full
screen mode)?
Code:
function Zoom(imgName,imgWidth,imgHeight,oPosL,oPosT) {
//Center window from center of screen
//oPosL and oPosT are center of screen - (screen.width/2) etc.
var TempLeft = (imgWidth / 2);
var TempTop = (imgHeight / 2);
var PosL = (oPosL - TempLeft);
var PosT = (oPosT - TempTop);
zoomWindow = window.open '', 'zoomWin', 'width='+imgWidth+',height='+imgHeight
+',top='+PosT+',left='+PosL+',toolbar=0,menubar=0,location=0,scrollbars=0')
zoomWindow.window.resizeTo(imgWidth, imgHeight+30);
}
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 19th, 2004, 02:01 PM
#3
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 20th, 2004, 04:20 AM
#4
Send the centre of the window instead.
So how do you get the full screen width / height ?
Try window.Width and window.Height or something from the calling window... instead of the screen width/height.
You may have to account for resolution stil tho?
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 20th, 2004, 11:35 AM
#5
screen.width/2 and screen.height/2 gives you the center of the screen.
window.width returns as "undefined".
How and where should I be using it. I tried in the htm and the .js file.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 23rd, 2004, 04:50 AM
#6
Fanatic Member
this mate?
Code:
<html>
<head>
<style>
input{
font:9pt arial;
}
</style>
<script language="javascript">
function f(){
windowScreenX=window.screenX;
windowScreenY=window.screenY;
width=300;
height=160;
top=windowScreenY+(window.innerHeight/2);
left=windowScreenX+(window.innerWidth/2)-width/2;
s='width=' +width+ ',height=' +height+ ',top=' +top+ ',left=' +left;
window.open('sample.html','sample',s);
}
</script>
</head>
<body>
<input type=button value='click me' onclick='f()'>
</body>
</html>
-
Jul 24th, 2004, 01:26 AM
#7
Looks promissing! When I get some time from remodeling our
house this week, I will try it and let you know.
Thanks.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 30th, 2004, 03:14 PM
#8
window.innerWidth keeps coming up as undefined?
My code is in an external js file, if that matters?
Thanks.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 30th, 2004, 03:18 PM
#9
Frenzied Member
try document.innerHTML
don't know if that even works
maybe document.body.innerHTML
maybe put everything in a div called wee
thn do document.wee.innerHTML
Have I helped you? Please Rate my posts. 
-
Jul 31st, 2004, 10:23 PM
#10
But this is on an external js file. Guess I will have to settle for
center screen only, for now.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 1st, 2004, 08:49 AM
#11
Frenzied Member
it being an external file shouldn't matter.
Have I helped you? Please Rate my posts. 
-
Aug 4th, 2004, 06:01 PM
#12
Ok, thanks. I will do more testing.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|