André Alvarez
André Alvarez

Reputation: 131

Reload Parent window Javascript originated

So i have a form echo'ed in my PHP:

echo "<td class='btn'><a href=\"/php/editPs/unlinkWhere.php?product=".$row['item_id']."\"  onclick=\"goclicky(this); return false;\"  target=\"_blank\"><img src=\"img/unlink.png\" border=\"0\"></a></td>";

This is the JS funcion that it calls:

function goclicky(meh)
{
var x = screen.width/2 - 400/2;
var y = screen.height/2 - 300/2;
window.open(meh.href, 'Unlink','height=300,width=400,left='+x+',top='+y);
}

Then the page unlinkWhere.php loads in the middle of the screen and inside there is another form:

echo "<form action=\"/php/editPs/unlink.php\" onSubmit=\"return valida(); \" method=\"post\" >";

That submit's all data closes the popup and here is my problem, i cant figure out how to refresh/reload the previous page:

//if its validated then
if((valLOC!=0 && valTEA==0 && valPERSONFIELD==0)||(valLOC==0 && valLOCDES=='' && valTEA!=0 )){
            //hide error div
    erro.style.display='none';


            //DOES NOT WORK
    window.opener.document.location.reload(true);


    window.close();
    return true;

    } else{
        erro.style.display='inline';
        return false;
        }   

I think my problem is that i am generating the href link through js and the parent is not working... any ideias how can i do this?

Upvotes: 0

Views: 4510

Answers (1)

C M
C M

Reputation: 703

try this

<script>
    window.onunload = refreshParent;
    function refreshParent() {
        window.opener.location.reload();
    }
</script>

hope it helps...

Upvotes: 1

Related Questions