?
Solved

HTML code for "Open in a Maximized window"

Posted on 2005-05-04
14
Medium Priority
?
762 Views
Last Modified: 2012-05-05
What is the HTML code to cause a page to open in a Maximized window, and set focus to itself?

Thanks,
BassKozz
0
Comment
Question by:basskozz
  • 6
  • 5
  • 3
14 Comments
 
LVL 32

Expert Comment

by:Batalf
ID: 13932232
Something like this?

    <script language="Javascript">
    function openWindow(){    
        var adjustHeight = 60;
        var adjustWidth = 15;
        var height = screen.availHeight-adjustHeight;
        var width = screen.availWidth-adjustWidth;        
        var winProps = "height="+height+",width="+width+",left=0,top=0,resizable=yes";        
        var theWin = window.open("aPage.html","theWin",winProps);
        theWin.focus();
    }
    openWindow();
       
    </SCRIPT>
0
 

Author Comment

by:basskozz
ID: 13932252
I was looking for something more like HTML code, not java...
Can this be done ?
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13932259
No, you can't control the size of the window by HTML. You can set target on your <a> tag(example: <a href="aPage.html" target="_blank">A link</a>), but you can't control the size of the window.

btw: The code above is Javascript, not Java so there's no need for the Java software.

Batalf
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:basskozz
ID: 13932283
Batalf,

Is there any code (HTML, javascript, etc...) that I can put in a *.htm file so that as soon as it is opend it will maximize itself...

My understanding of the script you sent me is that it will open a new page... but i need it to be put into the current page.

I know this is probably confusing, let me know if you have any questions.
-BassKozz
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13932292
You can put this into your page

<script language="Javascript">
    function resizeWindow(){    
        var adjustHeight = 60;
        var adjustWidth = 15;
        var height = screen.availHeight-adjustHeight;
        var width = screen.availWidth-adjustWidth;        
        self.resizeTo(width,height);
        self.focus();
    }
    resizeWindow();
       
    </SCRIPT>

That will maximize the page.
0
 
LVL 32

Accepted Solution

by:
Batalf earned 1400 total points
ID: 13932303
Forgot one line in the function. You also have to move the window to coordinate 0,0(top left corner)

This is the new one:

<script language="Javascript">
    function resizeWindow(){    
        var adjustHeight = 60;
        var adjustWidth = 15;
        var height = screen.availHeight-adjustHeight;
        var width = screen.availWidth-adjustWidth;    
        self.moveTo(0,0);  
        self.resizeTo(width,height);
        self.focus();
    }
    resizeWindow();
       
    </SCRIPT>
0
 

Author Comment

by:basskozz
ID: 13932309
still not opening maximized... it is just a bigger page... but it doesn't fill the screen and center it self.

I am bumping the points as this is a harder question than I initially thought.

-BassKozz
0
 

Author Comment

by:basskozz
ID: 13932313
oops... to fast for me...


Ok, now it centers it self to the top left... the only thing is it still isn't maximized (doesn't fill the entire screen) just a big window

-Basskozz
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13932781
Batalf,

On a kibbutz, I'm getting correct results with no screen adjust in IE 6 and FireFox, FYI

var adjustHeight = 0;
var adjustWidth = 0;

----------------------------------------------------------------------------------------------------

Basskozz,

The above may or may not work for you as well.  This is Batalf's solution not mine, so do not award any points to me, not even an assist.

Thanks,
Rod
0
 

Author Comment

by:basskozz
ID: 13932818
Rod,

That did it... As you wish I will not award any points to you for this fix.
But I must ask you two questions:
1. Why? (no points or assist)
2. Why did Batalf's script have:
        var adjustHeight = 60;
        var adjustWidth = 15;
as opossed to your settings:
var adjustHeight = 0;
var adjustWidth = 0;

???

Thanks,
BassKozz
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13932956
>Why? (no points or assist)

I'm sure Batalf knows as much or more than I do regarding JavaScript.  He would have corrected this on his next post.  I was just lurking and saved you some time.  I really did no work and contributed nothing of value that Batalf wouldn't have gotten to on his own.  There are plently of people that will hop on someone elses answer and post a typo correction after another expert has worked diligently to answer a question and expect credit for no real work or contribution to the solution.  I am not one of those people.

>Why did Batalf's script have:

Depending on the browser, and which function you use to obtain the screen width, you may need an offset.  In this case it was apparently not needed.  It migh be needed in Opera or Safari.  I only tested on the two most popular browsers.

It is pretty obvious Batalf wrote this to answer your question rather than copy and pasted.  He deserves full credit and an A for his answer.

0
 

Author Comment

by:basskozz
ID: 13932978
Thanks guys !!!

-BassKozz
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13934688
Glad we could help!

Thank you for rdivilbiss for assisting me while I was asleep:-)

Batalf
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13935108
No problem, Batalf.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month16 days, 21 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question