Javascript: Member Not found

I was using the following code to open the pdf files using popup. 

User come to a page that has 2 links that open with the below function. both opens a  pdf. If the user clicks the pdf link and then minimizes it and then clicks the other link  the Member not found error generates.

WRONG 

function popUp(strURL, strType, strWidth, strHeight, winName, leftPos, topPos) {
    var strOptions="";
    if (strType=="nocontrols") {
        strOptions="scrollbars,resizable,height="+ strHeight+",width="+strWidth+",left="+leftPos+",top="+topPos;
    }
    if (strType=="controls") {
        strOptions="toolbar,menubar,location,scrollbars,resizable,height="+strHeight+",width="+strWidth+",left="+leftPos+",top="+topPos;
    }
  var   newWin = window.open(strURL, winName, strOptions);   

newWin.focus() 

 The problem was when the window opens it lost is reference & parent window throws the error use the following modified code to resolve this issue.

 RIGHT

var newWin;
function popUp(strURL, strType, strWidth, strHeight, winName, leftPos, topPos) {
    var strOptions="";
    if (strType=="nocontrols") {
        strOptions="scrollbars,resizable,height="+ strHeight+",width="+strWidth+",left="+leftPos+",top="+topPos;
    }
    if (strType=="controls") {
        strOptions="toolbar,menubar,location,scrollbars,resizable,height="+strHeight+",width="+strWidth+",left="+leftPos+",top="+topPos;
    }
    newWin = window.open("", winName, strOptions);
    newWin.close();
    newWin = window.open(strURL, winName, strOptions);
    if (window.focus)
    {
    newWin.focus()
    }
}

 

5 Replies to “Javascript: Member Not found”

  1. This works great! Thanks

    A small problem the window closes everytime and opens new window again. Is there any way to avoid that?

    Thanks
    Harry

Leave a Reply to Harry Cancel reply

Your email address will not be published. Required fields are marked *