Solved

window.createpopup question

Posted on 2002-04-18
10
1,284 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
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

 

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

695 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