Link to home
Start Free TrialLog in
Avatar of damunj
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.backgroundColor = "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>
Avatar of knightEknight
knightEknight
Flag of United States of America image

try this:

<BUTTON ID="Btn" onclick="ButtonClick2(document.getElementById('msg'))">Click Me!</BUTTON>
actually, you may have to reverse the double and single quotes for VBScript:


<BUTTON ID="Btn" onclick='ButtonClick2(document.getElementById("msg"))'>Click Me!</BUTTON>
Avatar of damunj
damunj

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.
Avatar of damunj

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.
<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.backgroundColor = "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('msg2')">Click Me!</BUTTON>
<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
I hate you!
ASKER CERTIFIED SOLUTION
Avatar of sriram_in
sriram_in

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry the replace the oPopup.show line with this.

  oPopup.show 25, 25, 180, 50, document.getElementById(x)  

Bye,
Sriram.
May I know why you accepted th second working example?

CJ