Home > Archive > JScript > February 2005 > Position new window using createPopup()
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Position new window using createPopup()
|
|
| Solomon 2005-02-14, 3:58 am |
| On my web site I need to use a popup window. Code is very simple and on my
local machine it works just fine. Strange thing happens when I upload and run
same code from the server. Again, everything works fine except the y-position
of the popup window. It should start from zero, very top of my screen (not
the document) as it does when I run this locally. Any suggestions? Here is
complete code:
<html>
<head>
<title>My site</title>
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<script>
var oPopup = window.createPopup();
function detailWindow()
{
a1.src = 'dresses1/646L.jpg';
oPopup.document.body.innerHTML = pop.innerHTML;
oPopup.show(160, 0, 780, 680);
}
</script>
</head>
<body bgcolor="660000">
<img width="263px" height="360px" onclick="detailWindow();"
src="dresses1/646m.jpg" style="LEFT: 320px; CURSOR: hand; POSITION: absolute;
TOP: 33px">
<DIV ID="pop" STYLE="DISPLAY: none">
<div style="BACKGROUND: #cba5a4; WIDTH: 100%; HEIGHT: 100%">
<input type="button" value="Close" onclick="parent.oPopup.hide();"
style="LEFT: 20px; CURSOR: hand; COLOR: #660000; POSITION: absolute; TOP:
630px">
</div>
<div style="position: absolute; top:51px; left:250px; width:500px;
height:600px;">
<img id="a1" src="" width="500px" height="600px">
</div>
</DIV>
</body>
</html>
| |
| Randy Webb 2005-02-14, 3:58 am |
| Solomon wrote:
> On my web site I need to use a popup window. Code is very simple and on my
> local machine it works just fine. Strange thing happens when I upload and run
> same code from the server. Again, everything works fine except the y-position
> of the popup window. It should start from zero, very top of my screen (not
> the document) as it does when I run this locally. Any suggestions? Here is
> complete code:
>
> <html>
> <head>
> <title>My site</title>
> <meta content="http://schemas.microsoft.com/intellisense/ie5"
> name="vs_targetSchema">
> <script>
> var oPopup = window.createPopup();
> function detailWindow()
> {
> a1.src = 'dresses1/646L.jpg';
> oPopup.document.body.innerHTML = pop.innerHTML;
> oPopup.show(160, 0, 780, 680);
<--snip-->
It seems that there is a 5th argument to .show, and that is the element
that you want your coordinates to be relative to. I hunted in MSDN and
could not find where its documented (I didn't hunt long so it may indeed
be there).
The example on this page:
<URL
http://msdn.microsoft.com/library/d...createPopup.asp
/>
gives this line for the show part:
oPopup.show(100, 100, 180, 25, document.body);
And indeed positions the popup with respect to the body. Changing it to
this:
oPopup.show(100, 100, 180, 25, myButton);
Along with this HTML:
<button id="myButton">
Will cause the popup to be positioned with respect to myButton.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup w ly
| |
| Bob Barrows [MVP] 2005-02-14, 8:57 am |
| Randy Webb wrote:
>
> <--snip-->
>
> It seems that there is a 5th argument to .show, and that is the
> element that you want your coordinates to be relative to. I hunted in MSDN
> and
> could not find where its documented (I didn't hunt long so it may
> indeed be there).
>
> The example on this page:
>
> <URL
> http://msdn.microsoft.com/library/d...createPopup.asp
> />
The link to the show() method was right at the bottom of this page. Here is
the link:
http://msdn.microsoft.com/workshop/...ethods/show.asp
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
| |
| Dave Methvin 2005-02-14, 3:58 pm |
| On XP SP2, the popup can't be outside the browser window that created it,
unless the user has loosened the Internet Zone defaults. (Tools, Internet
Options, "Allow script-created windows without size or position
constraints")
http://www.microsoft.com/uk/windows...means.mspx#EDAA
"Solomon" <Solomon@discussions.microsoft.com> wrote in message
news:C7DD0833-C45D-49B6-820A-5A5CE228E187@microsoft.com...
> On my web site I need to use a popup window. Code is very simple and on my
> local machine it works just fine. Strange thing happens when I upload and
> run
> same code from the server. Again, everything works fine except the
> y-position
> of the popup window. It should start from zero, very top of my screen (not
> the document) as it does when I run this locally. Any suggestions? Here is
> complete code:
>
> <html>
> <head>
> <title>My site</title>
> <meta content="http://schemas.microsoft.com/intellisense/ie5"
> name="vs_targetSchema">
> <script>
> var oPopup = window.createPopup();
> function detailWindow()
> {
> a1.src = 'dresses1/646L.jpg';
> oPopup.document.body.innerHTML = pop.innerHTML;
> oPopup.show(160, 0, 780, 680);
> }
> </script>
> </head>
> <body bgcolor="660000">
> <img width="263px" height="360px" onclick="detailWindow();"
> src="dresses1/646m.jpg" style="LEFT: 320px; CURSOR: hand; POSITION:
> absolute;
> TOP: 33px">
> <DIV ID="pop" STYLE="DISPLAY: none">
> <div style="BACKGROUND: #cba5a4; WIDTH: 100%; HEIGHT: 100%">
> <input type="button" value="Close" onclick="parent.oPopup.hide();"
> style="LEFT: 20px; CURSOR: hand; COLOR: #660000; POSITION: absolute; TOP:
> 630px">
> </div>
> <div style="position: absolute; top:51px; left:250px; width:500px;
> height:600px;">
> <img id="a1" src="" width="500px" height="600px">
> </div>
> </DIV>
> </body>
> </html>
| |
| Randy Webb 2005-02-14, 8:57 pm |
| Dave Methvin wrote:
> On XP SP2, the popup can't be outside the browser window that created it,
> unless the user has loosened the Internet Zone defaults. (Tools, Internet
> Options, "Allow script-created windows without size or position
> constraints")
I have Windows XP SP2 with the default settings but I can definitely
position a popup created with window.createPopup()
> http://www.microsoft.com/uk/windows...means.mspx#EDAA
While it may be true for the UK version of WinXP it is not true of the
US version that I have. I can post screen shots if desired.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup w ly
| |
| Randy Webb 2005-02-14, 8:57 pm |
| Bob Barrows [MVP] wrote:
> Randy Webb wrote:
>
>
>
>
> The link to the show() method was right at the bottom of this page. Here is
> the link:
>
> http://msdn.microsoft.com/workshop/...ethods/show.asp
>
> Bob Barrows
Thanks Bob. I knew it was going to be simple and something I overlooked.
<smacking self on head>
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup w ly
| |
| Michael Harris \(MVP\) 2005-02-14, 8:57 pm |
| Randy Webb wrote:
> Dave Methvin wrote:
>
> I have Windows XP SP2 with the default settings but I can definitely
> position a popup created with window.createPopup()
>
>
> While it may be true for the UK version of WinXP it is not true of the
> US version that I have. I can post screen shots if desired.
The default for this varies by zone/level...
My IE6 sp1 on XP sp2 (US version) has the option enabled for 'My Computer',
'Local Intranet', and 'Trusted Sites', but disabled for the Internet and
Restricted zones. I've never set this option on/off manually.
--
Michael Harris
Microsoft MVP Scripting
| |
| Randy Webb 2005-02-15, 3:59 am |
| Michael Harris (MVP) wrote:
> Randy Webb wrote:
>
>
>
>
> The default for this varies by zone/level...
>
> My IE6 sp1 on XP sp2 (US version) has the option enabled for 'My Computer',
> 'Local Intranet', and 'Trusted Sites', but disabled for the Internet and
> Restricted zones. I've never set this option on/off manually.
In the Local Zone, the option:
"Allow script initiated windows without size or position constraints"
Is disabled. Its set to the default level (Medium) yet when running this
code:
var oPopup = window.createPopup();
function detailWindow()
{
a1.src = 'dresses1/646L.jpg';
oPopup.document.body.innerHTML = pop.innerHTML;
oPopup.show(160, 0, 780, 680);
}
With a smaller than desktop browser window, it will overlay everything
and put the popup outside the browser window. I am understanding
correctly that your setup duplicates this behavior?
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup w ly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
| |
| Dave Methvin 2005-02-15, 3:59 pm |
| > In the Local Zone, the option:
>
> "Allow script initiated windows without size or position constraints"
>
> Is disabled. Its set to the default level (Medium) yet when running this
> code:
>
> var oPopup = window.createPopup();
> function detailWindow()
> {
> a1.src = 'dresses1/646L.jpg';
> oPopup.document.body.innerHTML = pop.innerHTML;
> oPopup.show(160, 0, 780, 680);
> }
>
> With a smaller than desktop browser window, it will overlay everything and
> put the popup outside the browser window. I am understanding correctly
> that your setup duplicates this behavior?
I double-checked and the "Allow script initiated windows without size or
position constraints" option seems to be doing what it says it should. With
the option disabled, the popup is constrained so that it cannot cover the
address bar above or the status bar below, although it can poke out of the
window horizontally. I used the Local Intranet and Internet zones for my
testing.
| |
| Michael Harris \(MVP\) 2005-02-16, 3:58 am |
| > I double-checked and the "Allow script initiated windows without size
> or position constraints" option seems to be doing what it says it
> should. With the option disabled, the popup is constrained so that it
> cannot cover the address bar above or the status bar below, although
> it can poke out of the window horizontally. I used the Local Intranet
> and Internet zones for my testing.
Same behavior here using "My Computer" zone...
With the option enabled, the popup will extended beyond the client area both
verically and hoizontally.
With it disabled, vertical height/position of the popup is constrained to
the client area, leaving the address/status/et.al. bars visible, but it may
extended outside the client are horizontally.
--
Michael Harris
Microsoft MVP Scripting
|
|
|
|
|