Solved

window.createpopup question

Posted on 2002-04-18
10
1,256 Views
Last Modified: 2008-03-17
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>
0
Comment
Question by:damunj
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 6951049
try this:

<BUTTON ID="Btn" onclick="ButtonClick2(document.getElementById('msg'))">Click Me!</BUTTON>
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 6951052
actually, you may have to reverse the double and single quotes for VBScript:


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

Author Comment

by:damunj
ID: 6951172
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.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:damunj
ID: 6951194
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.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6951941
<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>
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6951943
I would use Javascript for such purposes, and different coding to make it work in Netscape too though.

CJ
0
 
LVL 3

Expert Comment

by:pleasenospam
ID: 6952300
I hate you!
0
 

Accepted Solution

by:
sriram_in earned 100 total points
ID: 6952652
try this...

<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, document.getElementById("msg")  

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>
0
 

Expert Comment

by:sriram_in
ID: 6952656
sorry the replace the oPopup.show line with this.

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

Bye,
Sriram.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6953230
May I know why you accepted th second working example?

CJ
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question