• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6198
  • Last Modified:

How to toggle full screen using Javascript?

Is it possible to use Javascript to allow users to toggle a full screen option if they wish?

I've found some Javascript that I think tries to execute the F11 for Firefox.

Is it possible to check the browser then depending on what browser it is, if the user chooses to go full screen and click a link to execute e.g. F11?

(I'm not sure how this would be done in Safari. Chrome and Opera also use F11 for full screen.)
<script type="text/javascript">
function max()
{
var obj = new ActiveXObject("Wscript.shell");
obj.SendKeys("{F11}");
}
</script>
</head>
<body onload="javascript:max()">

Open in new window

0
Apari
Asked:
Apari
1 Solution
 
leakim971PluritechnicianCommented:
Hello Apari,

You can't take control on the web browser window with Javascript.

Regards.
0
 
ApariAuthor Commented:
Hi leakim971,

Thank you for your response. I've checked out the code I attached above and it does work (albeit with an Active X warning), linking the javascript to an onclick in a link.

However it only works in IE. I'd like to know if there's a way to make it work with other browsers.
0
 
leakim971PluritechnicianCommented:
Have a look to this thread (you will find a lot on EE talking about full screen) :
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_24945463.html?sfQueryTermInfo=1+paypal+php

I know you hope something like use of ActiveX on FF or Chrome & Co. Perhaps try the latest version of Silverlight and FF...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
leakim971PluritechnicianCommented:
0
 
ApariAuthor Commented:
Okay I spent some time checking this out and it doesn't look like it's a possibility. The idea was to be able to toggle full screen using a link that would trigger the F11 key for full screen toggle which is initiated if you use F11 on the keyboard (FF/IE/Opera/Chrome). Would be an interesting solution especially if using jquery slideshows.

0
 
experts1Commented:
Apari,

If you are interested in a solution which does not use F11 sendkey method, then please let me know and I will post the solution!
0
 
MangagmCommented:
there are two javascript functions you can use:

From w3:
window.resizeBy() Resizes a window by the specified pixels
and
window.resizeTo() Resizes a window to the specified width and height

so you can use resizeTo(1024,800) where the numbers are the resolution of the client's monitor, there are some other properties that hold those values, I think they're called clientX or something like that, you can look that in w3chools.com

to recognize the explorer you can use :

if(document.all){
     // this code will only work in IE
}else{
     // everything else, opera and firefox are based on netscape so are really a like
}

for chrome dont really know, havent really worked a lot with it

there's also an object with the description of the browser: navigator.appName

hope this helps
0

Featured Post

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now