Solved

window.createpopup question

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

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Zoom web page in asp.net 2 37
.Net Web Site Password specs 2 21
SVG Star 4 18
addressing a specific html page 9 29
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now