devxlogo

window.open() method

window.open() method

Question:
HI! I hope you can help me. I’m opening a window with the window.open() method, and for the life of me, I can’t get it to be the size I want in NS4.Here’s the code:This works in IE4, but NS4 opens the new window in a full screen. I tried using innerWidth and innerHeight, they didn’t work either. What am I doing wrong? Thanks for your help!

Answer:
The problem here is that Navigator is more picky than Internet Explorer when parsing the third, windowFeatures, parameter. You have a space between the comma (,) after the width parameter and the height parameter. This is bad. When Netscape sees this it get all confused.Change your code to read:window.open(“bbimages/” + name + “.html”, “name”, “width=300,height=300”)Finally, as a matter of habit you show make sure that the window was actually opened as a result of your command. Use the following code to do this:newWindow = window.open(“bbimages/” + name + “.html”, “name”, “width=300,height=300”)if (newWindow != null) { // do something here with the new window}

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist