动态弹出窗口 [英] dynamic popup

查看:50
本文介绍了动态弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有两个按钮调用相同的功能打开弹出窗口,

根据传递给函数的参数构建。


问题:当我点击第一个按钮(或第二个按钮)时,任何

都会消失。当我再次调用该函数时(即从athor按钮),我

得到没有窗口的子代码:也就是说,第二个弹出窗口首先加载到

,松开我也是......


我只需要这个替换:这可能吗?


感谢所有人提前,PM


---


< script>

函数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) +"," ;;

feature + =" 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。写(" 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> ;

解决方案

playmaker写道:


我有两个按钮调用相同的功能打开一个弹出窗口,根据传递给函数的参数构建。

问题:当我点击第一个按钮(或第二个按钮)时,任何东西都会消失。当我再次调用该函数时,也就是说,从athor
按钮调用该函数时,我没有得到任何窗口替换:也就是说,第二个弹出窗口首先加载到
,失去w和h ...... br />
我只需要这个替代品:这可能吗?

感谢大家提前,PM

---
< script>
函数openPop(url,nome,w,h,pD,tD){
var features ="" ;;
features = =" scrollbars = no, " ;;
feature = =" menubar = no," ;;
feature = =" resizable = no," ;;
features + =" left =" + Math .floor(screen.width / 2-w / 2)+"," ;;
feature + =" top =" + Math.floor(screen.height / 2-h / 2)+" ;," ;;
要素+ =" alwaysRaised = yes," ;;
要素+ =" width =" + w +"," ;;
feature + =" 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>


不确定问题是什么 - 通常的罪魁祸首是使用两个窗口同名的

,但你没有这样做。无论如何,

脚本上有胡须,还有一些奇怪的东西

(''alwaysRaised''只适用于签名脚本,例如),代码是

尽可能低效。 JS禁用也没有。

试试这个:


<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 // EN"

" http://www.w3.org/TR/html4/strict.dtd">

< html>

< head>

< title>无标题< / title>

< script type =" text / javascript">


函数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 +''" ;宽度= QUOT; + W +"高度= QUOT; + H +" title ="''+ tD +''">'',

''< / body>'',

''< / html> ''

] .join('''');

nw = window.open(''javascript :opener.HTML'' ,nome,features);

if(nw&&!nw.closed&& nw.focus)

nw.focus();

返回false;

}


< / script>

< / head>

< body>

< a href =" desert.jpg" onclick ="返回

openPop(this.href,''des'',''499'',''610'',''desert'')"> b1< / a>

< a href =" cactus.jpg" onclick ="返回

openPop(this.href,''tus'','''330'','''630'',''cactus'')"> b2< / a>

< / body>

< / html>


不要使用弹出窗口,等等哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇/>

第二:我很抱歉奇怪,但这是我的第一个js功能,

所以请原谅......

而且......我给了你从html调用函数的代码,但我忘了

说我正在用Flash调用函数:


on(release){

u =" popup.htm" ;;

n =''nnn'';

ww = 450;

hh = 560;

img =''cactus.jpg'';

tt =''Titletitle' ';


getURL(" javascript :openPop(" +"''" + u +"''" +'' '' + QUOT; '' & + n +和+,++和+ ww +,和+,+和+++ hh + ;''" +'',''+"''" + img +"''" +'',''+"''" + tt +"''" + ")");

}


我收到来自PHP / MySQL和我的那些变量(u,n,ww等)的值

使用它们打开弹出窗口。为什么弹出窗口?简单:它是一个视觉艺术家(画家)的网站,网站的内容是他的作品(我为页面添加了10

缩略图,我点击了他们打开弹出窗口)。使用单个弹出框的

的想法是避免一个用户同时在

打开10个弹出窗口...所以我不得不调解一个解决方案...


感谢cose,现在我必须了解如何在swf文件中使用它。


最好的问候,

PM




我试过你的代码按原样 (没有Flash)

但是没有用(IE 6,Firefox 1)......我不明白为什么......


PM


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>

解决方案

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.


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


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

PM


这篇关于动态弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆