Window.Open Function

M

Matt

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=javascript>
function popup(filename)
{
var
newWin=window.open(filename,'default','menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,hotkeys=no,width=400,height=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=javascript>
function popup(filename, p_height, p_width)
{
var
newWin=window.open(filename,'default','menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,hotkeys=no,width='+p_width+',height='+p_height+');
newWin.focus();
}
</script>

HTML function call = onClick='popup('service.asp',500,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.
 
W

web.dev

Matt said:
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=javascript>
function popup(filename)
{
var
newWin=window.open(filename,'default','menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,hotkeys=no,width=400,height=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=javascript>
function popup(filename, p_height, p_width)
{
var
newWin=window.open(filename,'default','menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,hotkeys=no,width='+p_width+',height='+p_height+');
newWin.focus();

At the end where you have:

....height='+p_height+');

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

....height=' + p_height);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top