Javascript 使用javascript打开弹出窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14351771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 16:28:39  来源:igfitidea点击:

Open Popup window using javascript

javascript

提问by Roomy

I am looking to open one aspx page (test.aspx) in two different popup windows at the same time.

我希望同时在两个不同的弹出窗口中打开一个 aspx 页面 (test.aspx)。

what I have till now second replace first one and page recreate in first.

到目前为止我所拥有的第二个替换第一个并首先重新创建页面。

I think it require more clarification here so,

我认为这里需要更多的澄清,所以,

Basicaly I create a graph and place it in test.aspx, and save that graph as image file. I put a button on test.aspx which linked with stimulsoft report and that report show pdf format of that image. Now if i open with test.aspx it replace the image page. but I want to see both graph and pdf same time. One solution is I create a new blank aspx page to display report but I try avoid to add new page because it is possible to mount report on test.aspx.

基本上我创建了一个图形并将其放置在 test.aspx 中,并将该图形保存为图像文件。我在 test.aspx 上放了一个按钮,它与 stimulsoft 报告链接,该报告显示该图像的 pdf 格式。现在,如果我用 test.aspx 打开它会替换图像页面。但我想同时查看图形和 pdf。一种解决方案是我创建一个新的空白 aspx 页面来显示报告,但我尽量避免添加新页面,因为可以在 test.aspx 上安装报告。

The question is just to open a single POPUP window twice on same time, but may be it is posible or not. and each and every popup containing there own dynamic controls and report like mrt.

问题只是同时打开一个 POPUP 窗口两次,但可能是否可行。每个弹出窗口都包含自己的动态控件和报告,如 mrt。

回答by Umesh

Change the window name in your two different calls:

在两个不同的调用中更改窗口名称:

function popitup(url,windowName) {
       newwindow=window.open(url,windowName,'height=200,width=150');
       if (window.focus) {newwindow.focus()}
       return false;
     }

windowName must be unique when you open a new window with same url otherwise the same window will be refreshed.

当您打开具有相同 url 的新窗口时,windowName 必须是唯一的,否则将刷新相同的窗口。

回答by Sankalp Mishra

To create a popup you'll need the following script:

要创建弹出窗口,您需要以下脚本:

<script language="javascript" type="text/javascript">

function popitup(url) {
newwindow=window.open(url,'name','height=200,width=150');
if (window.focus) {newwindow.focus()}
return false;
}


</script>

Then, you link to it by:

然后,您通过以下方式链接到它:

  <a href="popupex.html" onclick="return popitup('popupex.html')">Link to popup</a>

If you want you can call the function directly from document.ready also. Or maybe from another function.

如果需要,您也可以直接从 document.ready 调用该函数。或者可能来自另一个函数。

回答by Wolf

First point is- showing multiple popups is not desirable in terms of usability.

第一点是 - 就可用性而言,显示多个弹出窗口是不可取的。

But you can achieve it by using multiple popup names

但是您可以通过使用多个弹出名称来实现它

var newwindow;
function createPop(url, name)
{    
   newwindow=window.open(url,name,'width=560,height=340,toolbar=0,menubar=0,location=0');  
   if (window.focus) {newwindow.focus()}
}

Better approach will be showing both in a single page in two different iFrames or Divs.

更好的方法将在两个不同的 iFrame 或 Div 的单个页面中显示。

Update:

更新:

So I will suggest to create a new tab in the test.aspx page to show the report, instead of replacing the image content and placing the pdf.

所以我会建议在test.aspx页面新建一个tab来展示报告,而不是替换图片内容并放置pdf。