views:

106

answers:

5

How to open the homepage in FULLSCREEN with javascript without opening a new window ??

A: 

It is not possible to do this with JavaScript without using a new window (and this can vary from browser to browser).

Only external applications, such as Flash, can create full screen events.

graham
+9  A: 

To start with, please don't do that. Changing the browser size without the user's consent is usually very annoying.

Some modern browsers don't allow JavaScript to resize the browser window (I'm assuming this is what you mean by full screen) if the window wasn't opened by a script. The only way to get around that is to change the browser's configuration. So, essentially, if the browser doesn't allow it, there's nothing you can do. You'll have to open a new popup and resize it to fill the screen (and annoy some users).

Ates Goral
+1 for leaving my browser alone. Write the web application, do not mess with my client browser!
Chris
A: 

you could try to set window.innerHeight/window.innerWidth and the window position with javascript to create a faked "fullscreen-look-a-like"-effect. but note that this wouldn't work cross-browser/cross-os.

but: why the hell do you want to do this? if it's a "normal" webpage the only effect you'll get is banish and annoy your visitors. if it's a intranet-application with only some users that know what happens, it would be easier to tell them they should better press F11.

oezi
+4  A: 

I assume you're doing this in direct response to the user clicking a button saying "go fullscreen" or similar. Mind you, every browser I know of already has that built in.

You could use the window.moveTo (MDC link, MSDN link) and window.resizeTo methods (MDC link, MSDN link). The browser may disallow it, although if it's in direct response to a user action, it may allow it. In any case, it's non-standard.

Frankly, though, it's off-topic but I think you're much better off opening a new window (being clear with the user what you're doing) in virtually all UX cases. Opening a full-screen window via window.open is straightforward and (if done in direct response to a user-generated event) well-supported.

T.J. Crowder
`window.resizeTo` doesn't work in IE from a tab.
Tim Down
@Tim: Good! I don't think either of them work on Chrome at all.
T.J. Crowder
A: 

Write a function in javascript

document.getElementById('<%=btnSubmit.ClientID%>').onclick(function(){
 window.location = "http://myweb.com/home";
return false;
});
ImadArif
..........huh??
T.J. Crowder
`getElementByID` should be `getElementById`, there was no mention of (what I assume to be) ASP.NET anywhere in the question, DOM elements don't have a click method, and setting window.location won't cause the browser to resize the window.
David Dorward
@David: Yeah, well, but other than *that*...
T.J. Crowder
@T.J.: Other than that, `return false` isn't indented properly!!!
Ates Goral
@Ates: LOL! ....
T.J. Crowder