【问题标题】:window.open is having issue with firefoxwindow.open 与 Firefox 有问题
【发布时间】:2013-10-05 13:46:12
【问题描述】:

我正在使用window.open 方法在myhtml 中打开一个新网页。但是当我在 Firefox 中运行它时,它会重新加载同一页面。但它适用于 Chrome 和 Safari。这是我的 html 和 javascript sn-p。我正在使用 Python Flask frameworkJinja 模板。我也尝试使用location.replace 而不是window.open

        </div>
        <form name="items">
            <script type="text/javascript" language="javascript">
                function getdetails(name){
                    window.open("/details?name="+name,"_self")
                }
            </script>
            <table id="main" align="center" class="table table-striped table-bordered" >
                <thead>
                <tr>
                    <th> <strong> SNo </strong></th>
                    <th> <strong> name </strong></th>
                    <th> <strong> item </strong></th>
                    <th> <strong> Total numbers </strong></th>
                    <th> <strong> size </strong></th>
                </tr>
                </thead>
                {% set count = 1 %}
                <tbody id="tablebody">
                {% for i in rows %}
                    {% for name,values in i.iteritems() %}
                        <tr>
                            <td style="text-align: center"> {{ count }}</td>
                            <td> <a href=# id=link onclick="getdetails('{{ name }}');"> {{ name }} </a> </td>
                            {% for j in values %}
                                <td>  {{ j }}  </td>
                            {% endfor %}
                        </tr>
                    {% endfor %}
                    {% set count = count + 1 %}
                {% endfor %}
                </tbody>
            </table>
        </form>
        </div>

【问题讨论】:

  • 您想将其作为新标签页或新弹出窗口打开吗?
  • 我有点不清楚,你是想在新窗口中打开内容还是在同一窗口中打开不同的页面?
  • 我需要打开一个新标签。无需打开弹出窗口

标签: javascript python html firefox jinja2


【解决方案1】:

尝试使用 window.location.href 而不是 window.open,location.href 是属性而不是方法,因此您必须以不同的方式调用它,但它确实像页面重定向一样工作,尽管我会尝试找出 window.open 出了什么问题 - 这是更“正确”的方式。

 window.location.href = 'http://www.google.com';

由于您的问题有点不清楚,如果您想在新标签页中打开页面,请在 window.open 方法中将 _self 更改为 _blank。

 window.open("/details?name="+name,"_blank");

【讨论】:

  • 我想在标签中打开。我删除了 _self 但没有运气
  • 不要删除 _self - 将其更改为“_blank” - firefox 将在主窗口中打开该参数中的任何其他标签...它必须是“_blank”才能创建新标签。
猜你喜欢
  • 1970-01-01
  • 2014-12-30
  • 1970-01-01
  • 1970-01-01
  • 2011-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多