【问题标题】:New window popup is blank in chrome, but works in IE and firefox新窗口弹出在 chrome 中为空白,但在 IE 和 firefox 中有效
【发布时间】:2022-02-08 23:02:27
【问题描述】:

这是我的代码。

<form name = "SearchForm" id = "SearchForm" 
    method = "post" 
    onSubmit =
        "<%if(contextType.equals("EXAM")){%>
             window.open('', 'searchResults',
                         'width = 615, height = 515,
                          resizable = yes, scrollbars = yes');
         <%}%>
         doSearch('resultsdiv',1);
         return false;"
>

新窗口在 chrome 中打开时没有搜索结果,但在 Firefox 和 IE 中打开时有搜索结果。

【问题讨论】:

  • 你的弹窗拦截器打开了吗?
  • 弹出窗口打开..但弹出窗口在 chrome 中是空白的。但在 Firefox 中它有一些结果

标签: javascript html google-chrome


【解决方案1】:

我遇到了类似的问题。问题是因为提交按钮自动回发一次,我在同一个按钮上附加了一个javascript函数,这使得回发两次。为了解决这个问题,我禁用了提交按钮的自动回发,只需将按钮的属性“AutoPostBack”设置为“False”就可以了。

【讨论】:

    【解决方案2】:
    <form name = "SearchForm" id = "SearchForm" method = "get" target=searchResults onSubmit="window.open('', 'searchResults', 'width = 615, height = 515, resizable = yes, scrollbars = yes'); return true;">
    <input type="text" name="foo" size="15" value="Hello World!">
    <input type="Submit" value="Try">
    </form>
    <script>
    var x=self.location.href.split('=');
    if(x.length==2){
    document.write('<h3>You have successfully popped up a search for: '+unescape(x[1].replace(/\+/gi,' ')).replace(/\</gi,'&lt;'));
    
    };
    </script>
    

    此处的示例:(死链接) 补充:target=searchResults,改回true

    我还将 post 更改为 get(以便您可以看到它传输了查询;POST 可以正常工作)并剥离了您的特定内容,但现在可以使用。在 Chrome 和 FF 中测试,很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-02
      • 1970-01-01
      • 2012-07-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多