?
Solved

window.createpopup question

Posted on 2002-04-18
10
Medium Priority
?
1,290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

801 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