473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.floor(screen.width/2-w/2)+",";
features += "top="+Math.floor(screen.height/2-h/2)+",";
features += "alwaysRaised=yes,";
features += "width=" + w + ",";
features += "height=" + h;
nw = window.open(url, nome, features);
nw.document.open();
nw.document.write("<html>");
nw.document.write("<head>");
nw.document.write("<title>"+tD+"</title>");
nw.document.write("</head>");
nw.document.write("<body leftmargin='0' topmargin='0' marginwidth='0'
marginheight='0'>");
nw.document.write("<img src="+pD+" width="+w+" height="+h+" title="+tD+">");
nw.document.write("</body>");
nw.document.write("</html>");
nw.document.close()
}

</script>
<a
href="javascript:openPop('popup.htm','des','499',' 610','desert.jpg','desert')">b1</a>
<a
href="javascript:openPop('popup.htm','tus','330',' 630','cactus.jpg','cactus')">b2</a>
Jul 23 '05 #1
11 4114
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.floor(screen.width/2-w/2)+",";
features += "top="+Math.floor(screen.height/2-h/2)+",";
features += "alwaysRaised=yes,";
features += "width=" + w + ",";
features += "height=" + h;
nw = window.open(url, nome, features);
nw.document.open();
nw.document.write("<html>");
nw.document.write("<head>");
nw.document.write("<title>"+tD+"</title>");
nw.document.write("</head>");
nw.document.write("<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>");
nw.document.write("<img src="+pD+" width="+w+" height="+h+" title="+tD+">"); nw.document.write("</body>");
nw.document.write("</html>");
nw.document.close()
}

</script>
<a
href="javascript:openPop('popup.htm','des','499',' 610','desert.jpg','desert')">b1</a> <a

href="javascript:openPop('popup.htm','tus','330',' 630','cactus.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.floor(screen.width/2-w/2) ,
'top='+Math.floor(screen.height/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('javascript:opener.HTML', nome, features);
if (nw && !nw.closed && nw.focus)
nw.focus();
return false;
}

</script>
</head>
<body>
<a href="desert.jpg" onclick="return
openPop(this.href,'des','499','610','desert')">b1</a>
<a href="cactus.jpg" onclick="return
openPop(this.href,'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("javascript: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.jpg" onclick="return
openPop(this.href,'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:black;">' ,
'<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:black;">' ,
'<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
playmaker wrote:
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:black;">' ,
'<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.


Looks OK here. Try substituting:

...............
...............
HTML = [
'<html>' ,
'<head>' ,
'<title>'+tD+'</title>' ,
'</head>' ,
'<body style="margin:0;background:black;">' ,
'<img style="border-width:0;" src="'+pD+'" title="'+tD+'">' ,
'</body>' ,
'</html>'
].join('');
nw = window.open('javascript:opener.HTML', nome, features);
if (nw && !nw.closed && nw.focus)
nw.focus();
return false;
}

Make sure the image size is accurate. Images will resize in the browser
if the dimensions are set in HTML/CSS so, don't trust those properties.
Open the image (url) in its own window, or in your image editor.

Jul 23 '05 #11
RobB wrote:
playmaker wrote:
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:black;">' ,
'<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


I tryed anything:
anything goes if I resizeBy(0,-3)...

PM


correct.

Looks OK here. Try substituting:

..............
..............
HTML = [
'<html>' ,
'<head>' ,
'<title>'+tD+'</title>' ,
'</head>' ,
'<body style="margin:0;background:black;">' ,
'<img style="border-width:0;" src="'+pD+'" title="'+tD+'">' ,
'</body>' ,
'</html>'
].join('');
nw = window.open('javascript:opener.HTML', nome, features);
if (nw && !nw.closed && nw.focus)
nw.focus();
return false;
}

Make sure the image size is accurate. Images will resize in the browser
if the dimensions are set in HTML/CSS so, don't trust those properties.
Open the image (url) in its own window, or in your image editor.

Jul 23 '05 #12

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

Similar topics

3
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...
7
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...
3
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...
1
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...
3
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...
2
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...
0
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....
1
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...
1
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.