|
|
||||||
|
#1
|
|
|
|
|
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 |
|
|
|
#2
|
|
|
|
|
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 [..] > 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. |
|
#3
|
|
|
|
|
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 |
|
#4
|
|
|
|
|
Hi,
I tryed you code "as is" (without Flash) but is doesn't work (IE 6, Firefox 1)... I can't understand why... PM |
|
#5
|
|
|
|
|
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. |
|
#6
|
|
|
|
|
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 |
|
#7
|
|
|
|
|
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. |
|
#8
|
|
|
|
|
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 |
|
#9
|
|
|
|
|
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. |
|
#10
|
|
|
|
|
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: [..] |
|
#11
|
|
|
|
|
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 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. |
|
#12
|
|
|
|
|
RobB wrote:
> playmaker wrote: >> (3 >> dimensions > I tryed anything: anything goes if I resizeBy(0,-3)... PM [..] |
|
|
| Similar Threads | |
| Dynamic Popup in NewForm Hi I have two dropdown controls in my NewForm, my requirement is:- Based on the item selected in the first dropdown the second dropdown should populate values. Can any one... |
|
| dynamic popup menu I developing an dynamic project where outlook bar like display is used. my requirement is that on click of the button, i need to show the menu as a popup menu, but which... |
|
| Dynamic Popup Menu I developing an dynamic project where outlook bar like display is used. my requirement is that on click of the button, i need to show the menu as a popup menu, but which... |
|
| Dynamic Popup menu Hi, I have a custom calendar control like this: 1 2 3 4 5 6 7 8 9 10 Now, I would like... |
|
| Dynamic popup control Hello, Has anybody successfully created a dynamic popup menu control (ie, without relying on Menu resource) ? I have some problems with the following code: Rect controlRect... |
|
|
All times are GMT. The time now is 10:30 AM. | Privacy Policy
|