2

I am trying to trigger a JavaScript function from another page.
I have grid View in page 1 that allows the users to edit the data.
The Edit happens in popup page and if the edit is successful, the popup page will close.
To refresh the grid view with the new/ edited data JavaScript is being used.
MY question is how can i call the JavaScript Function in my page 1 from Popup page

function hide_loading() 
{
   document.getElementById('ContentPlaceHolder1_Button4').click();
}

Sorry for English "mistake"
Thank you

1
  • 2
    Save your javascript in a separate .js page and load it in using $.getScript("my_script.js",function(){//type your script here}); Voila, you can now use all functions in my_script.js in that function Commented Jun 2, 2015 at 10:02

2 Answers 2

1

Parent window:

function foo () {
    alert ("Hello!");
}

function openPopup() {
    var wo = window.open("popup.html");
}

Popup window:

function doSomething() {
    window.opener.foo();
}
Sign up to request clarification or add additional context in comments.

Comments

1

You can attach a handler to detect the closing of the popup window and in that event handler, place the code to refresh the data on your main page.

For example, on your main page

//open a popup window for editing
var windowReference = window.open('your_edit_window_url');

//attach a handler to know when the popup window is closed
windowReference.onload = function() {
   windowReference.onunload =  function () {
       //refresh your page data here using ajax or just a simple reload
   };
}

This way you are not calling functions of your main window from the popup window. Each window handles its own functionality

1 Comment

in the main page..when you are opening the popup using window.open

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.