弹出和设置数据? [英] Popup and set data?

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

问题描述



我正在尝试打开一个弹出窗口,然后设置一些数据,但我不能确定
似乎能让它工作。我肯定我错过了一些明显的东西。


popwin = document.open(''mypop.html'',\" external\,\\ \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n\\ n宽度= \" + w

+ \",height = \" + h +

\",resizable = no ,scrollbars = no,status = yes,location = no,toolbar = no,menubar = no\");

popwin.document.data.user = user;


mypop.html有< form name = data>使用名为user的元素在它。

基本上,我希望能够在其中弹出一个包含一些填充的

数据的窗口,但我无法弄清楚我该怎么做它。


谢谢。


-Greg G

解决方案

< blockquote>文章< V - ******************** @ ctc.net>, gg ********* @ CAKEctc.net

启发我们...


我正在尝试打开弹出窗口,然后设置一些数据,但我似乎无法使其正常工作。我肯定我错过了一些明显的东西。

popwin =


window.open。

不是文件。打开。

document.open(''mypop.html'',\" external \",\" width = \" + w
+ \\ \\,高度= \" + h +
\",resizable = no,scrollbars = no,status = yes,location = no,toolbar = no,menubar = no \") ;


必须首先加载窗口才能访问文档。在尝试此操作之前,您可能需要

a setTimeout:popwin.document.data.user = user;



-

- -

~kaeli~

很多钱都被污染了 - 它会污染你的并且它会污染我的。
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace


kaeli写道:

文章< V - ******************** @ ctc.net>, gg ********* @ CAKEctc.net
启发我们......

我正在尝试打开一个弹出窗口,然后设置一些数据,但我似乎无法使其正常工作。我确定我错过了一些明显的东西。

popwin =



window.open。
不是document.open。




这是我尝试过的最新迭代。这很奇怪,但

document.open的工作方式与window.open相同。或者至少,它是视觉上的。

document.open(''mypop.html'',\" external\\ \\,\" width = \" + w
+ \",height = \" + h +
\",resizable = no,scrollbars = no,status = yes,locatio n = no,toolbar = no,menubar = no\");



必须首先加载窗口才能访问文档。在尝试此操作之前,您可能需要
一个setTimeout:

popwin.document.data.user = user;




嗯。这是有趣的。这就是我的代码现在的样子:


函数setValue(win,val){

win.document.data.user = val; < br $>
}


函数popUpPassword(用户){

popwin = window.open(''mypop.html'',"外部",

" width = 500,height = 500,resizable = no,scrollbars = no,s tatus = yes,location = yes,toolbar = no,menubar = no");


setTimeout(''setValue(popwin,user)'',1000);

}


但是,当超时响起,我收到一个javascript错误说

用户未定义。它似乎在抱怨下一个功能的开始




它变得更奇怪了。我从显示源

输出中复制了上面的代码。但是,当我点击javascript错误

窗口中的链接时,它会显示:


< script Language =" JavaScript">

<! - 开始

函数popUpPassword(URL,w,h){

window.open(url," external", " width =" + w +",height =" + h +

",resizable = no,scrollbars = no,status = no,location = no,toolbar = no, menubar = no");

}

//结束 - >

< / script>

那只是完全是古怪的。我正在使用Firefox。 IE向我显示了一个类似的错误,但它几乎足够友好,可以向我展示代码。


-Greg G


在文章< Kp ******************** @ ctc.net>, gg ********* @ CAKEctc.net

启发我们...

setTimeout(''setValue(popwin,user)'',1000);
}
然而,当超时发生时,我收到一个javascript错误说
用户未定义。它似乎在抱怨下一个功能的开始!


是的,你不能这样做。

变量超出了setTimeout运行时的范围。让它们成为全球的b $ b。

它变得更加怪异。我从Show Source
输出中复制了上面的代码。但是,当我点击javascript错误
窗口中的链接时,它会显示:




什么链接?

可以你有缓存问题吗?

我经常使用Firefox。我有时需要控制+ shift + reload。


我假设两个页面都是你的,对吗?

把这个函数放在mypop.html中:


< script type =" text / javascript">

function setUser(user)

{

document.data.user = user;

}

< / script>


现在更改你的弹出脚本另一页:

函数popUpPassword(用户)

{

var win = null;

int count = 0;

win = window.open(''mypop.html''," external",

" width = 500,height =

500,resizable = no,scrollbars = no,status = yes,location = yes,toolbar = no,menubar = no"

);

while( win == null)

{

/ *给出加载时间,但不要让它成为无限循环。如果内容图像很重或需要很长时间,则将值更改为更高的数字



。此外,如果弹出窗口被阻止,则win将为null。 * /

count ++;

if(count == 5000)break;

}

if( win == null)返回false; / *就是不能这样做。如果你愿意,可以在这里添加错误处理

。* /


win.setUser(用户);

返回true;

}


-

-

~kaeli~

墨菲的定律#2030:如果一开始你没有成功,就要破坏你试过的所有证据。
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace



I''m trying to open a popup window and then set some data, but I can''t
seem to make it work. I''m sure I''m missing something obvious.

popwin = document.open(''mypop.html'', \"external\", \"width=\" + w
+\",height=\" + h +
\",resizable=no,scrollbars=no,status=yes,location= no,toolbar=no,menubar=no\");
popwin.document.data.user=user;

mypop.html has a <form name=data> with an element named "user" in it.
Essentially, I want to be able to pop up a window with some populated
data in it, but I can''t figure out how I can do it.

Thanks.

-Greg G

解决方案

In article <V-********************@ctc.net>, gg*********@CAKEctc.net
enlightened us with...


I''m trying to open a popup window and then set some data, but I can''t
seem to make it work. I''m sure I''m missing something obvious.

popwin =
window.open.
Not document.open.
document.open(''mypop.html'', \"external\", \"width=\" + w
+\",height=\" + h +
\",resizable=no,scrollbars=no,status=yes,location= no,toolbar=no,menubar=no\");
The window has to load first before you can access the document. You may need
a setTimeout before you try this: popwin.document.data.user=user;


--
--
~kaeli~
A lot of money is tainted - It taint yours and it taint mine.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace


kaeli wrote:

In article <V-********************@ctc.net>, gg*********@CAKEctc.net
enlightened us with...

I''m trying to open a popup window and then set some data, but I can''t
seem to make it work. I''m sure I''m missing something obvious.

popwin =


window.open.
Not document.open.



That was the latest iteration I had tried. It''s strange, but
document.open worked the same as window.open. Or at least, it did visually.

document.open(''mypop.html'', \"external\", \"width=\" + w
+\",height=\" + h +
\",resizable=no,scrollbars=no,status=yes,locatio n=no,toolbar=no,menubar=no\");


The window has to load first before you can access the document. You may need
a setTimeout before you try this:

popwin.document.data.user=user;



Hmmm. This is interesting. Here''s what my code looks like now:

function setValue(win,val) {
win.document.data.user = val;
}

function popUpPassword(user) {
popwin = window.open(''mypop.html'', "external",
"width=500,height=500,resizable=no,scrollbars=no,s tatus=yes,location=yes,toolbar=no,menubar=no");

setTimeout(''setValue(popwin,user)'',1000);
}

However, when the timeout goes off, I get a javascript error saying
that "user is not defined". It seems to be complaining about the start
of the next function!

It gets weirder. I copied the above code from the "Show Source"
output. However, when I click on the link in the javascript error
window, it shows this:

<script Language="JavaScript">
<!-- Begin
function popUpPassword(URL,w,h) {
window.open(url, "external", "width=" + w +",height=" + h +
",resizable=no,scrollbars=no,status=no,location=no ,toolbar=no,menubar=no");
}
// End -->
</script>

That''s just totally bizzare. I''m using Firefox. IE shows me a
similar error, but it''s nearly friendly enough to show me the code.

-Greg G


In article <Kp********************@ctc.net>, gg*********@CAKEctc.net
enlightened us with...

setTimeout(''setValue(popwin,user)'',1000);
}

However, when the timeout goes off, I get a javascript error saying
that "user is not defined". It seems to be complaining about the start
of the next function!
Yeah, you can''t do that.
The variables are out of scope by the time the setTimeout runs. Make them
global.

It gets weirder. I copied the above code from the "Show Source"
output. However, when I click on the link in the javascript error
window, it shows this:



What link?
Could you be having a problem with caching?
I often do with Firefox. I have to control+shift+reload sometimes.

I assume both pages are yours, correct?
Put this function in mypop.html:

<script type="text/javascript">
function setUser(user)
{
document.data.user = user;
}
</script>

Now change your popup script in the other page to:
function popUpPassword(user)
{
var win = null;
int count = 0;
win = window.open(''mypop.html'', "external",
"width=500,height=
500,resizable=no,scrollbars=no,status=yes,location =yes,toolbar=no,menubar=no"
);
while (win == null)
{
/* give time to load, but don''t let it be an endless loop. Change value
to a higher number if the content is image heavy or takes a long time
normally. Also, if popup was blocked, win will be null. */
count ++;
if (count == 5000) break;
}
if (win == null) return false; /* Just couldn''t do it. Add error handling
here if you want.*/

win.setUser(user);
return true;
}

--
--
~kaeli~
Murphy''s Law #2030: If at first you don''t succeed, destroy
all evidence that you tried.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace


这篇关于弹出和设置数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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