如何在子窗口打开时停止刷新父页面? [英] how to stop refreshing parent page while child window open?

查看:78
本文介绍了如何在子窗口打开时停止刷新父页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击链接打开子窗口时,父页面会自动刷新。我怎样才能阻止它?



父页不应该在打开子窗口时刷新。这个怎么做?请帮助我。



我的代码如下:

  < HTML> 
< head>
< title>登入< / title>
< meta http-equiv =Content-Typecontent =text / html; charset = iso-8859-1>

< script type =text / javascript>
var popup;
函数ShowPopup(url){
if(popup)
{
popup.close();
}
popup = window.open(url,self,toolbar = no,scrollbars = yes,location = no,statusbar = no,menubar = no,resizable = 0,width = 300, height = 350,left = 0,top = 0);
popup.focus();
}
< / script>

< / head>

< body>
< a href =onclick =ShowPopup('popup_login.asp')style =color:#1686CC;>登录/注册< / a>
< / body>
< / html>


解决方案

写回假() ; window.open() JS方法之后的



在壳体上面的片段不工作,改变默认<按钮> 标签正常< input> 标签,其中 type =button。这将解决问题。



下面是代码片断:





JavaScript

 < script> 
函数tagedlist(){
window.open(http://w3schools.com,mywindow,menubar = 1,resizable = 1,width = 1000,height = 1000);
返回false;
}
< / script>


when i click link to open child window, parent page refresh automatically. how can i stop it?

parent page should not refresh while open child window. how to do this? please help me.

my code is as below given:

<html>
<head>
<title>login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">
var popup;
function ShowPopup(url) {
if(popup)
    {
     popup.close();
     }
    popup = window.open(url, "self", "toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=0,width=300,height=350,left = 0,top = 0");
        popup.focus();
 }
</script>

</head>

<body>
<a href="" onclick="ShowPopup('popup_login.asp')" style="color: #1686CC;">Sign In / Register</a>
</body>
</html>

解决方案

Write return false(); after the window.open() JS method.

In case the above snippet is not working, change the default <button> tag to normal <input> tag with type="button". This will solve the problem.

Below is the code snippet:

JavaScript

<script>
  function tagedlist() { 
    window.open("http://w3schools.com","mywindow","menubar=1,resizable=1,width=1000,height=1000");
    return false;           
  }
</script>

这篇关于如何在子窗口打开时停止刷新父页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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