damunj
asked on
window.createpopup question
I'm creating a web page using VBScript that uses the window.createpopup feature. Everything works perfectly if I hardcode the location element in the oPopup.show call. For example:
oPopup.show 25, 25, 180, 50, btn
This will display the popup window as an offset of the "btn" object. However, if I pass the location of the object as a parameter (as is shown in the code below), the popup window appears as an offset of the browser rather than the passed-in object.
A copy of the code that doesn't work is attached below.
Any advice?
Thanks
Mitch
<HTML>
<HEAD>
<TITLE>Popup Example</TITLE>
<SCRIPT LANGUAGE="VBScript">
dim oPopup
function ButtonClick2(x)
set oPopup = window.createPopup
set oPopBody = oPopup.document.body
oPopBody.style.backgroundC olor = "lightyellow"
oPopBody.style.border = "solid black 1px"
oPopBody.innerHTML = "Click outside <B>popup</B> to close.<BR>"
oPopup.show 25, 25, 180, 50, x
end function
</SCRIPT>
</HEAD>
<BODY>
<BUTTON ID="Btn" onclick="ButtonClick2(msg) ">Click Me!</BUTTON>
<span id="msg"></span>
<BR><BR><BR>
<span id="msg2"></span>
</BODY>
</HTML>
oPopup.show 25, 25, 180, 50, btn
This will display the popup window as an offset of the "btn" object. However, if I pass the location of the object as a parameter (as is shown in the code below), the popup window appears as an offset of the browser rather than the passed-in object.
A copy of the code that doesn't work is attached below.
Any advice?
Thanks
Mitch
<HTML>
<HEAD>
<TITLE>Popup Example</TITLE>
<SCRIPT LANGUAGE="VBScript">
dim oPopup
function ButtonClick2(x)
set oPopup = window.createPopup
set oPopBody = oPopup.document.body
oPopBody.style.backgroundC
oPopBody.style.border = "solid black 1px"
oPopBody.innerHTML = "Click outside <B>popup</B> to close.<BR>"
oPopup.show 25, 25, 180, 50, x
end function
</SCRIPT>
</HEAD>
<BODY>
<BUTTON ID="Btn" onclick="ButtonClick2(msg)
<span id="msg"></span>
<BR><BR><BR>
<span id="msg2"></span>
</BODY>
</HTML>
actually, you may have to reverse the double and single quotes for VBScript:
<BUTTON ID="Btn" onclick='ButtonClick2(docu ment.getEl ementById( "msg"))'>C lick Me!</BUTTON>
<BUTTON ID="Btn" onclick='ButtonClick2(docu
ASKER
Sorry Knight. The popup element seems to be doing the same thing for me. The popup menu location should be set from the msg span but it still shows as located from the browser itself.
Could it be a browser version thing? I'm running IE5.5.
Could it be a browser version thing? I'm running IE5.5.
ASKER
Sorry Knight. The popup element seems to be doing the same thing for me. The popup menu location should be set from the msg span but it still shows as located from the browser itself.
Could it be a browser version thing? I'm running IE5.5.
Could it be a browser version thing? I'm running IE5.5.
<HTML>
<HEAD>
<TITLE>Popup Example</TITLE>
<SCRIPT LANGUAGE="VBScript">
dim oPopup
function ButtonClick2(x)
set oPopup = window.createPopup
set oPopBody = oPopup.document.body
oPopBody.style.backgroundC olor = "lightyellow"
oPopBody.style.border = "solid black 1px"
oPopBody.innerHTML = "Click outside <B>popup</B> to close.<BR>"
oPopup.show 25, 25, 180, 50, eval(x)
end function
</SCRIPT>
</HEAD>
<BODY>
<BUTTON ID="Btn" onclick="ButtonClick2('msg 2')">Click Me!</BUTTON>
<span id="msg"></span>
<BR><BR><BR>
<span id="msg2"></span>
</BODY>
</HTML>
<HEAD>
<TITLE>Popup Example</TITLE>
<SCRIPT LANGUAGE="VBScript">
dim oPopup
function ButtonClick2(x)
set oPopup = window.createPopup
set oPopBody = oPopup.document.body
oPopBody.style.backgroundC
oPopBody.style.border = "solid black 1px"
oPopBody.innerHTML = "Click outside <B>popup</B> to close.<BR>"
oPopup.show 25, 25, 180, 50, eval(x)
end function
</SCRIPT>
</HEAD>
<BODY>
<BUTTON ID="Btn" onclick="ButtonClick2('msg
<span id="msg"></span>
<BR><BR><BR>
<span id="msg2"></span>
</BODY>
</HTML>
I would use Javascript for such purposes, and different coding to make it work in Netscape too though.
CJ
CJ
I hate you!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry the replace the oPopup.show line with this.
oPopup.show 25, 25, 180, 50, document.getElementById(x)
Bye,
Sriram.
oPopup.show 25, 25, 180, 50, document.getElementById(x)
Bye,
Sriram.
May I know why you accepted th second working example?
CJ
CJ
<BUTTON ID="Btn" onclick="ButtonClick2(docu