Jump to content

How to refresh the main page after pop up window?


michaelkirby

Recommended Posts

Hi,

 

I'm new to JavaScript and starting to learn it more, but stuck on an issue and wondered if anyone could provide me with any information.

 

I have a profile page where a picture specific to the user is displayed. Using JavaScript I have a link which opens up a pop up window of an upload form allowing the user to change the particular picture. The user can choose the picture they desire then click upload and the window automatically closes.

 

However this is where the issue is. The main page which is where the profile picture is doesn't update the picture until the page is refreshed.

 

I looked into ways to refresh the page which is possible by setting the refresh of the page to every 5 or 10 seconds, however this is not really practical to refresh the page every 5 or 10 seconds.

 

Is there any better solutions to the issue at all??

Link to comment
Share on other sites

To refer back to the window that open the child window, use "opener".

opener.location.reload(true);

If you wish to refresh the image only, you can simply assign an ID to the image and use the child window to refresh it:

var profileImage = opener.document.getElementById("profileImage");
profileImage.src = "upload/newImage.jpg";

 

These codes did not tested yet. I just write it out on the spot. Please tell me if it's not working.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.