如何在Javascript中从另一个页面刷新页面 [英] How to refresh a page from another page in Javascript

查看:205
本文介绍了如何在Javascript中从另一个页面刷新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在页面上有一个按钮,单击此按钮,弹出窗口打开(弹出窗口也是一个aspx页面)。在弹出窗口中执行某些操作后,使用window.close()关闭它。现在关闭此弹出窗口后,我想刷新主页面(放置按钮的位置)。我怎样才能在Javascipt中做到这一点?任何人都可以帮助我吗?



提前致谢。

解决方案

只需在代码后面添加此代码即可打开弹出窗口。



window.location.reload;



它肯定会解决您的问题。


您好,



这是解决方案(此功能是刷新父窗口并关闭弹出窗口)。



 function closePopupWindow(){
window.opener.location.reload();
window.close();
}







如果您有任何疑问,请告诉我。



如果这样做有用,请提供投票,如果这是正确的话,请接受答案回答::ros:



谢谢,

Imdadhusen


 //例如,你有两个页面,即 page1.aspx  page2.aspx  
//,你想刷新 page1.aspx 通过 page2.aspx 然后
//在aspx区域的 page2.aspx 页面中添加此代码







< script type = text / javascript >

function RefreshParent(){

// if(window.opener!= null&& !window.opener.closed){

window .opener。 location .href = page1.aspx;

// self.close(); // page2.aspx关闭的代码
// }
}
window .onbeforeunload = RefreshParent;

< / script >







  //  并添加 page2.aspx.cs 页面,您要进行此活动的位置,按钮上的含义//单击或其他控制事件 





ScriptManager.RegisterStartupScript (页面, typeof (页面), OpenWindow RefreshParent(); true );


Hi,

I have a button in a page, on clicking this button, a pop-up opens up(the pop-up is also an aspx page). After some action is performed in the pop-up, it is closed by using window.close(). Now after this pop-up is closed, I want to refresh the main page (in which the button is placed). How can I do this in Javascipt? Can anyone help me?

Thanks in advance.

解决方案

Just add this code right after the code for opening the pop up.

window.location.reload;

It will solve your problem for sure.


Hi,

This is solution(this function is refresh parent window and close popup window as well).

function closePopupWindow(){
   window.opener.location.reload();
   window.close();
}




Please do let me know, if you have any doubt.

Please provide "Vote" if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Thanks,
Imdadhusen


//for example you have two pages i.e.  page1.aspx and page2.aspx
//and you want refresh page1.aspx through page2.aspx then
//add this code in page2.aspx page in aspx region







<script type="text/javascript">
       
        function RefreshParent() {

            //if (window.opener != null && !window.opener.closed) {

                window.opener.location.href = "page1.aspx";

                //self.close(); //code for page2.aspx close
            //}
        }
        window.onbeforeunload = RefreshParent;
   
    </script>




//and add in page2.aspx.cs page, where you want to this activity,Means on button //click or other control event





  ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "RefreshParent();", true);


这篇关于如何在Javascript中从另一个页面刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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