Window.Open Function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt

    Window.Open Function

    I have a function that I call from an HTML page to open a pop-up
    window. I would like to make the height and width as parameters but I
    jeep getting an "Object Expected" javascript error. I am not a js guru
    so I could use a little help. Here si my function:

    <script language=javasc ript>
    function popup(filename)
    {
    var
    newWin=window.o pen(filename,'d efault','menuba r=no,toolbar=no ,location=no,di rectories=no,st atus=yes,scroll bars=yes,resiza ble=yes,hotkeys =no,width=400,h eight=150');
    newWin.focus();
    }
    </script>

    HTML function call = onClick='popup( 'service.asp')

    The above works fine.

    I have tried this but get the error mentioned above:

    <script language=javasc ript>
    function popup(filename, p_height, p_width)
    {
    var
    newWin=window.o pen(filename,'d efault','menuba r=no,toolbar=no ,location=no,di rectories=no,st atus=yes,scroll bars=yes,resiza ble=yes,hotkeys =no,width='+p_w idth+',height=' +p_height+');
    newWin.focus();
    }
    </script>

    HTML function call = onClick='popup( 'service.asp',5 00,500)

    I assume my syntax is off is some way but I do not know how? Again, all
    I want to do is make the height and width as parameters of the function
    as I do with the filename.

  • web.dev

    #2
    Re: Window.Open Function


    Matt wrote:[color=blue]
    > I have a function that I call from an HTML page to open a pop-up
    > window. I would like to make the height and width as parameters but I
    > jeep getting an "Object Expected" javascript error. I am not a js guru
    > so I could use a little help. Here si my function:
    >
    > <script language=javasc ript>
    > function popup(filename)
    > {
    > var
    > newWin=window.o pen(filename,'d efault','menuba r=no,toolbar=no ,location=no,di rectories=no,st atus=yes,scroll bars=yes,resiza ble=yes,hotkeys =no,width=400,h eight=150');
    > newWin.focus();
    > }
    > </script>
    >
    > HTML function call = onClick='popup( 'service.asp')
    >
    > The above works fine.
    >
    > I have tried this but get the error mentioned above:
    >
    > <script language=javasc ript>
    > function popup(filename, p_height, p_width)
    > {
    > var
    > newWin=window.o pen(filename,'d efault','menuba r=no,toolbar=no ,location=no,di rectories=no,st atus=yes,scroll bars=yes,resiza ble=yes,hotkeys =no,width='+p_w idth+',height=' +p_height+');
    > newWin.focus();[/color]

    At the end where you have:

    ....height='+p_ height+');

    You have an unterminated string. It should end as follows:

    ....height=' + p_height);
    [color=blue]
    > }
    > </script>
    >
    > HTML function call = onClick='popup( 'service.asp',5 00,500)
    >
    > I assume my syntax is off is some way but I do not know how? Again, all
    > I want to do is make the height and width as parameters of the function
    > as I do with the filename.[/color]

    Comment

    • Matt

      #3
      Re: Window.Open Function

      Thank you very much. That worked out great for me. I knew it had to be
      my syntax.

      Comment

      Working...