Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6389897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:27:40+00:00 2026-05-25T03:27:40+00:00

Can anybody see what’s wrong with my code? It behaves properly in IE but

  • 0

Can anybody see what’s wrong with my code? It behaves properly in IE but firefox 6 seems to ignore any height or width settings that I pass through to the javascript window.open call. I can’t see anything obviously wrong with it but javascript isn’t my first language so I may be making a noob error somewhere in this.

The purpose of this function is to open an 800×600 window centered on the screen and displayed modally in both IE and Mozilla family browsers.

<html>
<head>

<script language="javascript" type="text/javascript">
    function openWindow(pageURL,Title,w,h) 
    {
        var left = (screen.width/2)-(w/2);
        var top = (screen.height/2)-(h/2);
        if (window.showModalDialog) {
            window.showModalDialog(pageURL,Title,'dialogWidth:' + w     + 'px,dialogHeight:'+ h + 'px,dialogTop:'+ top + 'px,dialogLeft:' + left + ',resizable=no');
        } else {
            window.open(pageURL,Title,"toolbar=no, location=no, directories=no,     status=no, menubar=no, scrollbars=yes,resizable=no,modal=yes,     copyhistory=no,width=" + w + ", height=" + h + ", top=" + top + ", left=" + left)
        }
    }   

</script>
</head>
<body>
<a href="javascript:openWindow('http://www.google.com','Google',800,600);">Launch</a>
</body>
</html>

Just to clarify a bit, the function is designed to test for the presence of ShowModalDialog (presuming that only IE supported it) and fall into the proper window.open branch in everything that supports the W3C window.open command which implements the “Modal” option. The idea being that if ShowModalDialog was implemented then it would use that otherwise use the window.open with the “Modal” option.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:27:41+00:00Added an answer on May 25, 2026 at 3:27 am

    Semi-colons, not commas, in showModalDialog:

    <html>
    <head>
    
    <script language="javascript" type="text/javascript">
        function openWindow(pageURL,Title,w,h) 
        {
            var left = (screen.width - w) / 2;
            var top = (screen.height - h) / 2;
            var options;
            if (window.showModalDialog) {
                options = 'dialogwidth:' + w     + ';dialogheight:'+ h + ';dialogtop:'+ top + ';dialogleft:' + left + ';resizable=no';
                console.log(options);
                window.showModalDialog(pageURL, Title, options);
            } else {
                options = "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes,resizable=no,modal=yes, copyhistory=no, width=" + w + ", height=" + h + ", top=" + top + ", left=" + left;
                console.log("window.open options: " + options);
                window.open(pageURL, Title, options)
            }
        }   
    
    </script>
    </head>
    <body>
    <a href="javascript:openWindow('http://www.google.com','Google',800,600);">Launch</a>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody see what is wrong with this code. it does not show up
I have written program for drawing pythagoras tree fractal. Can anybody see any way
Can anybody see where I am going wrong with this? I am trying to
Hello can anybody see why this query fails? SELECT A.idAd, A.ads_in_Cat, A.title, A.currency, A.price,
Can anybody see an error with this? The error I get is: 1>MainForm.cpp(71): error
Does anybody see anything wrong with the following function? ( Edit : no, I
Can anybody explain why I see another web site at my http secure address.
Can anybody tell me how to remove all CA2202 warnings from the following code?
Can anybody give me an example how to use the osgi framework classes? I
Can anybody know how to remove all the indexes from database ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.