473,800 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamic popup

Hi,
I have two buttons calling the same funtion to open a popup window,
dinamically built according to parameters passed to the function.

The problem: when I click the first button (or the second), anything
goes. When I call the function again /that is, from the athor button), I
get no window subtitution: that is, the second popup loads into the
first, loosing w and h too...

I simply need this substitution: is this possible?

Thanks to everybody in advance, PM

---

<script>
function openPop(url, nome, w, h, pD, tD) {
var features = "";
features += "scrollbars=no, ";
features += "menubar=no ,";
features += "resizable=no," ;
features += "left="+Math.fl oor(screen.widt h/2-w/2)+",";
features += "top="+Math.flo or(screen.heigh t/2-h/2)+",";
features += "alwaysRaised=y es,";
features += "width=" + w + ",";
features += "height=" + h;
nw = window.open(url , nome, features);
nw.document.ope n();
nw.document.wri te("<html>");
nw.document.wri te("<head>");
nw.document.wri te("<title>"+tD +"</title>");
nw.document.wri te("</head>");
nw.document.wri te("<body leftmargin='0' topmargin='0' marginwidth='0'
marginheight='0 '>");
nw.document.wri te("<img src="+pD+" width="+w+" height="+h+" title="+tD+">") ;
nw.document.wri te("</body>");
nw.document.wri te("</html>");
nw.document.clo se()
}

</script>
<a
href="javascrip t:openPop('popu p.htm','des','4 99','610','dese rt.jpg','desert ')">b1</a>
<a
href="javascrip t:openPop('popu p.htm','tus','3 30','630','cact us.jpg','cactus ')">b2</a>
Jul 23 '05 #1
11 4155
playmaker wrote:
Hi,
I have two buttons calling the same funtion to open a popup window,
dinamically built according to parameters passed to the function.

The problem: when I click the first button (or the second), anything
goes. When I call the function again /that is, from the athor button), I get no window subtitution: that is, the second popup loads into the
first, loosing w and h too...

I simply need this substitution: is this possible?

Thanks to everybody in advance, PM

---

<script>
function openPop(url, nome, w, h, pD, tD) {
var features = "";
features += "scrollbars=no, ";
features += "menubar=no ,";
features += "resizable=no," ;
features += "left="+Math.fl oor(screen.widt h/2-w/2)+",";
features += "top="+Math.flo or(screen.heigh t/2-h/2)+",";
features += "alwaysRaised=y es,";
features += "width=" + w + ",";
features += "height=" + h;
nw = window.open(url , nome, features);
nw.document.ope n();
nw.document.wri te("<html>");
nw.document.wri te("<head>");
nw.document.wri te("<title>"+tD +"</title>");
nw.document.wri te("</head>");
nw.document.wri te("<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0 '>");
nw.document.wri te("<img src="+pD+" width="+w+" height="+h+" title="+tD+">") ; nw.document.wri te("</body>");
nw.document.wri te("</html>");
nw.document.clo se()
}

</script>
<a
href="javascrip t:openPop('popu p.htm','des','4 99','610','dese rt.jpg','desert ')">b1</a> <a

href="javascrip t:openPop('popu p.htm','tus','3 30','630','cact us.jpg','cactus ')">b2</a>

Not precisely sure what the problem is - the usual culprit is use of
the same name for both windows, but you didn't do that. In any event,
that script has whiskers on it, along with some oddities
('alwaysRaised' only works with signed scripts, e.g.), and the code is
about as inefficient as possible. Nothing for the JS-disabled either.
Try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>untitled </title>
<script type="text/javascript">

function openPop(pD, nome, w, h, tD)
{
var features = [
'scrollbars=no' ,
'menubar=no' ,
'resizable=no' ,
'left='+Math.fl oor(screen.widt h/2-w/2) ,
'top='+Math.flo or(screen.heigh t/2-h/2) ,
'width=' + w,
'height=' + h
].join(',');
HTML = [
'<html>' ,
'<head>' ,
'<title>'+tD+' </title>' ,
'</head>' ,
'<body style="margin:0 ;">' ,
'<img src="'+pD+'" width="'+w+'" height="'+h+'" title="'+tD+'"> ' ,
'</body>' ,
'</html>'
].join('');
nw = window.open('ja vascript:opener .HTML', nome, features);
if (nw && !nw.closed && nw.focus)
nw.focus();
return false;
}

</script>
</head>
<body>
<a href="desert.jp g" onclick="return
openPop(this.hr ef,'des','499', '610','desert') ">b1</a>
<a href="cactus.jp g" onclick="return
openPop(this.hr ef,'tus','330', '630','cactus') ">b2</a>
</body>
</html>

Don't use pop-ups, blah blah blah...I'll spare you the lecture.

Jul 23 '05 #2
Hi,
first of all thanks.

Second: I'm sorry for the oddities but it is my first js function ever,
so excuse me...

And... I gave you the code to call a function from html but I forgot to
say that I'm calling the function from Flash this way:

on (release) {
u = "popup.htm" ;
n = 'nnn';
ww = 450;
hh = 560;
img = 'cactus.jpg';
tt = 'Titletitle';

getURL("javascr ipt:openPop("+" '"+u+"'"+','+"' "+n+"'"+','+"'" +ww+"'"+','+"'" +hh+"'"+','+"'" +img+"'"+','+"' "+tt+"'"+") ");
}

I receive the values of those vars (u, n, ww etc.) from PHP/MySQL and I
use them to open popups. Why popups? Simple: it is the site of a visual
artist (a painter) and the substance of the site is his work (I put 10
thumbnails for page and I click on them to open the popups). The idea of
using one single popup is to avoid that one user opens 10 popup at the
same time... So I had to "mediate" a solution...

Thanks for the cose, now I must understand how use it from the swf file.

best regards,
PM

Jul 23 '05 #3
Hi,
I tryed you code "as is" (without Flash)
but is doesn't work (IE 6, Firefox 1)... I can't understand why...

PM
Jul 23 '05 #4
If there's a line break after 'return' (in the link),
remove it.

Should be easy enough to modify...no need to pass a url, since you're
just generating a new document anyway; the only url you need is
that of the pic. I prefer loading a window with a favelet (javascript:)
over
the usual document.writes . (Much) less likely to encounter timing
problems
that way.

Take a look at some of the slide shows at

http://slayeroffice.com/index.php

Imaginative, and done within the same window, avoiding blocker problems

and the like.

Jul 23 '05 #5
everything is very beautyful there... :-)

Anyway, the code (don't know why) it is not working:
it opens a page as it was open using "_blank" and display the image in
the page: every toolbar is there, so any other attrubute... It IS a new
page, not a popup and I can't see the source ("html" is grayed)...

Thanks, PM

Jul 23 '05 #6
This must be on one line:

<a href="desert.jp g" onclick="return
openPop(this.hr ef,'des','499', '610','desert') ">b1</a>

Remove any carriage returns.

Jul 23 '05 #7
fantastic...
Only one thing: on IE6 I get a little white space under the image (3 or
4 pixel): is there any way to eliminate it?

Thanks, PM
Jul 23 '05 #8
playmaker wrote:
fantastic...
Only one thing: on IE6 I get a little white space under the image (3 or 4 pixel): is there any way to eliminate it?

Thanks, PM


Try modifying these lines:

'<body style="margin:0 ;background:bla ck;">' ,
'<img src="'+pD+'" width="'+w+'" height="'+h+'" title="'+tD+'"
border="0">' ,

(each one on ONE line only)...make sure you've got the image dimensions
correct.

Jul 23 '05 #9
Hi, I tried but it's the same:
the features are correct (w and h):
the problem is only for IE6/XP/SP2... :-(

PM

RobB wrote:
playmaker wrote:
fantastic.. .
Only one thing: on IE6 I get a little white space under the image (3


or
4 pixel): is there any way to eliminate it?

Thanks, PM

Try modifying these lines:

'<body style="margin:0 ;background:bla ck;">' ,
'<img src="'+pD+'" width="'+w+'" height="'+h+'" title="'+tD+'"
border="0">' ,

(each one on ONE line only)...make sure you've got the image dimensions
correct.

Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3233
by: gb | last post by:
Hi, How do you print a dynamically produced popup. Everything I try such as self.print() prints out the original or parent page. Banging my head against a wall time? Can the popup object be named and referenced through the DOM. The popup object has been named in the window.open() method. But all references to this fail to print the current window.
7
2114
by: bu | last post by:
I have a form with a handful of comments fields. I am trying to code the form in such a way that when the user clicks on the field, a dialog box will open up displaying the full contents of the field. I want to reuse the same window for each field ( seems sensless to code a screen n times for n fields when the only thing that is really changing is the source data ), but am having all sorts of issues. I have tried dynamically setting the...
3
6832
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to figure out, if there is a way of using polymorphic way (if that is a word) of doing this particular property. A sample of my code is as follows: DynamicControls.ButtonControl(this,btnSearchByName, new Point(5, 75), new Size(95, 20),...
1
4305
by: tribal boy | last post by:
Guys, I am using a dynamic menu which uses xml,xsl a css file and javascript. This works fine when there are no server controls around or underneath it. The problem is whenever the menu encounters a server control, it closes itself.
3
4793
by: RahimAsif | last post by:
I am writing an application that requires the a portion of the main menu to be dynamic. The menu has file, panels, view files and help across the top. The view files sub menu needs to be dynamically generated, and the dynamic generation needs to occur right when the user selects this menu item (that is on the Popup event handler). However, everytime I put following code on the Popup event handler (of the View Files menuitem) to dynamically...
2
3910
by: lrlebron | last post by:
I am trying to create popup windows with dynamic variable names and then see if they exist or not. For example, if I call the function like so openWin("2600","2000") I would like the function to create a window called "win26002000". I have tried the following code (and many other variations) but I cannot get it to work function openWin(senderID, recipientID) {
0
4539
by: benfly08 | last post by:
Hi, I used SWT to develop an windows application. In the application there is a dynamic created popup menu. The dynamic part is that i will pass a list of name to be a submenu of one menu item. However, when I code selection event, i cannot access to the list i pass in. Anybody got idea? Below is the code. public static void setUpMenu(final Shell shell, Menu popUpMenu, final String clientId) { myShell = shell; ...
1
4920
by: cdmsenthil | last post by:
I have an Infragistics UltrawebGrid . Each Row in the grid is attached to a context menu using Infragistics CSOM Upon click on the menu, I am creating an Iframe dynamically which points to another page in the same domain which also contains infragistics datagid populated with default data retrieved from Data Base. After creating the frame I am attaching it to the HTML DOM and show it as modal popup with OK and Cancel Button inside an...
1
3731
by: Peter | last post by:
ASP.NET 3.5 I am using HowerMenueExtender to do Balloon popups inside a DataList, and it works fine for static data, but I don't know how to display dynamic data, I don't know how/where to change this data. The data I am trying to display in the popup is not in the DataList. I've tried to use FindControl method to find the controls on the panel, but the FindMethod always returns nulls. How and where do I update the panel referenced...
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9090
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.