每次点击都会弹出一个新的弹出窗口 [英] new popup window on every click

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

问题描述

我有一个弹出窗口,我正在使用下面的脚本打开。每次点击,我都想打开新的弹出窗口。
我明白,拥有窗口的唯一名称将解决问题(在本例中为SampleWindow)。
保持窗户独特性的最佳方法是什么?有没有其他方法来管理javascript弹出窗口?

I've a pop up window which i'm opening using below script. On every click, i want to open new pop up. I understand, having unique name for the window will solve the problem (In this case "SampleWindow"). What's the best way to maintain the uniqueness of the window ? Is there any other way to manage javascript popup ?

window.open(url, 'SampleWindow', 'WIDTH=300,HEIGHT=250');


推荐答案

传递<$ c $的值c> _blank 到名称参数会将传递的 URL 加载到新窗口中即可。像这样:

Passing a value of _blank to the name parameter will load the passed URL into a new window. Like this:

window.open(url, '_blank', 'width=300,height=250');

name 参数的其他选项(可选)包括:

Other options for name parameter (optional) include:


  • _blank - URL已加载到新窗口中。这是默认

  • _parent - 网址已加载到父框架中

  • _self - 网址取代当前网页

  • _top - 网址替换任何可能加载的框架集

  • name - 窗口名称

  • _blank - URL is loaded into a new window. This is default
  • _parent - URL is loaded into the parent frame
  • _self - URL replaces the current page
  • _top - URL replaces any framesets that may be loaded
  • name - The name of the window

请注意,如果您要将此JavaScript传递给锚标记 A 该IE浏览器期望返回值,否则它将引用 A 标记本身。您的代码如下所示:

Do note that if you'll be passing this JavaScript to an anchor tag A that IE browsers expect a return value, otherwise it'll referrence the A tag itself. Your code for that would look like:

<a href="javascript:var w=window.open(url, '_blank', 'width=300,height=250');">test</a>

或更好(以避免向用户显示状态栏中的代码):

  <a href="javascript:void(0);" onclick="window.open(url, '_blank', 'width=300,height=250');">test</a>






链接:


Links:

  • window open() method reference
  • JSFiddle demo

这篇关于每次点击都会弹出一个新的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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