473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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=javascript>
function popup(filename)
{
var
newWin=window.open(filename,'default','menubar=no, toolbar=no,location=no,directories=no,status=yes,s crollbars=yes,resizable=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=javascript>
function popup(filename, p_height, p_width)
{
var
newWin=window.open(filename,'default','menubar=no, toolbar=no,location=no,directories=no,status=yes,s crollbars=yes,resizable=yes,hotkeys=no,width='+p_w idth+',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.

Sep 21 '05 #1
2 2005

Matt wrote:
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,s crollbars=yes,resizable=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=javascript>
function popup(filename, p_height, p_width)
{
var
newWin=window.open(filename,'default','menubar=no, toolbar=no,location=no,directories=no,status=yes,s crollbars=yes,resizable=yes,hotkeys=no,width='+p_w idth+',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);
}
</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.


Sep 21 '05 #2
Thank you very much. That worked out great for me. I knew it had to be
my syntax.

Sep 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michael | last post by:
I am trying to allow a user to view a PDF in a new window. I currently have this working using the following: <a href="./pdf.do?parameter=01121980" target="top"><b>pdf</b></a> The problem...
8
by: alanstew | last post by:
With the body tag calling out 'window onload', a function with a 'window.open' fails at the 'window.open' line. If I cut out the body tag, the function executes as normal. At first I thought it...
5
by: Mike | last post by:
In my previous post, I wrote: > ... > GOAL: (very simple) Provide a hyperlink which, when clicked, > calls a javascript function which opens a new URL. > ... > PROBLEM: The following code...
10
by: Marshall Dudley | last post by:
When I do the following line in Netscape, the popup loads as it should, but the parent window usually, but not always, reloads as well. <a href="#"...
2
by: Samir Pandey | last post by:
Hello, I am using the following javascript code to open a new window. Somehow, IE always opens a new window. It doesn't open target url in the window name given. All i want is, if there is a...
3
by: NeverLift | last post by:
But, if it's not open, I don't want to open it . . . using window.open will open it if it doesn't exist, even if the url in that open is null (the window is then empty -- but it's open). The...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
29
by: wayne | last post by:
Hey there... I'm having some problems passing url parameters with an open.window command. I'm not terribly familiar with java script but here is the code below. When executed it opens the...
8
by: johnsonholding | last post by:
Here is the code for a pop-up window that works in Firefox and not in IE - I get a java error or something, Here is the code : </script> <SCRIPT language="JavaScript"...
6
by: Jack | last post by:
I have a main webpage that has a list of records, each with a link to a window.open function call. As an example, a page that opens is editrecord.aspx?RecordID=34, and another is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.