By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,665 Members | 1,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,665 IT Pros & Developers. It's quick & easy.

new window full screen

P: n/a
Is there a javascript statement which can be incorporated in a
hyperlink which will open a new page that fills the screen while
leaving the page with the link open?

Thanks in advance.
CW
Jul 23 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Tue, 31 Aug 2004 15:28:37 GMT, pow67 <po***@optonline.net> wrote:
Is there a javascript statement which can be incorporated in a
hyperlink which will open a new page that fills the screen while
leaving the page with the link open?

Thanks in advance.
CW


<a href="newfile.html" target="newwin"
onclick="window.open(this.href, this.target, 'fullscreen'); return
false">Click me</a>
Note: fullscreen is IE only.

HTH

Al.
Jul 23 '05 #2

P: n/a
Thanks.
The script below works in IE but not Netscape- Any ideas?
<SCRIPT LANGUAGE="JavaScript">
<!--

function maximizeWin() {
if (window.screen) {
var aw = screen.availWidth;
var ah = screen.availHeight;
window.moveTo(0, 0);
window.resizeTo(aw, ah);
}
}

// -->
</SCRIPT>
<a href="myTestPage.htm" target="_blank" onclick="maximizeWin
()">Click Here</a></p>
Jul 23 '05 #3

P: n/a
Correction. The script in previous message works in Netscape but not IE.

Thanks in advance.

CW
Jul 23 '05 #4

P: n/a
On Tue, 31 Aug 2004 18:44:55 GMT, pow67 <po***@optonline.net> wrote:
Correction. The script in previous message works in Netscape but not IE.

Thanks in advance.

CW


I use the below script for NS7 & IE6.

<a href="filename.asp" target="newwin"
onclick="newWindow(this.href,this.target,
-1,-1,'yes','yes',0,0,'',false); return false;">click me</a>

HTH

Al.

function newWindow(sFilenameToView, sWindowName, iWidth, iHeight,
sCanScroll, bCanResize, iLeft, iTop, sExtraSettings, bReplaceHistory)
{
var oNewWin = null;
if (!sExtraSettings) {sExtraSettings='';}
// iWidth/iHeight=-1 for netscape to go "near as damit" full
screen
// NS user needs to press F11 to go true full screen.
if (iWidth == -1 || iHeight == -1) {
sExtraSettings =
sExtraSettings.replace(/fullscreen/gi, '');
if (sExtraSettings) {sExtraSettings += ',';}
sExtraSettings += 'fullscreen, outerWidth=' +
screen.width + ', outerHeight=' + screen.height;
iLeft = 0;
iTop = 0;
}
var iLeftPosition = iLeft;
var iTopPosition = iTop;
// iLeft/iTop=-1 centers the newwindow on the screen
if (iLeft == -1 || iTop == -1) {
iLeftPosition = (screen.availWidth) ?
(screen.availWidth - iWidth) / 2 : 0;
iTopPosition = (screen.availHeight) ?
(screen.availHeight - iHeight) / 2 : 0;
}

var sWindowSettings = 'height=' + iHeight + ',width=' + iWidth
+ ',top=' + iTopPosition + ',left=' + iLeftPosition + ',scrollbars=' +
sCanScroll + ',resizable=' + bCanResize + ',' + sExtraSettings;
oNewWin = window.open(sFilenameToView, sWindowName,
sWindowSettings, bReplaceHistory);
oNewWin.focus();
return oNewWin;
}

Jul 23 '05 #5

P: n/a
pow67 wrote:
Is there a javascript statement which can be incorporated in a
hyperlink which will open a new page that fills the screen while
leaving the page with the link open?
Yes, however it uses a feature of the DOM, not the core
language and so it is likely not to work in all UAs:

<a href="foo.html"
onclick="window.open(this.href, ..., "fullscreen"); return false;"...</a>


Note that fullscreen, if it works, may result in undesired presentation.
Use Google Groups for details.
PointedEars
--
completely foolproof was to underestimate the ingenuity of complete fools.
Jul 23 '05 #6

P: n/a
1) <a href="javascript: void();" onclick="window.open('new_window.htm',
'new_window','toolbar=no, status=no, menubar=no, resizeable=no')" > new
widow </a>

2) then, in the new_window.htm -- a wee bit of JS:

<head>
<script language="javascript" type="text/javascript">
self-resizeTo(screen.width,screen.height);
self-moveTo(0,0);
</script>
</head>

3) to provide the new window with an easy way out (other than the 'X' Close
in the upper right) provide for the use a <<back or <<home>> link (which
actually just closes the window, allowing the initial window to re-appear);
otherwise, you've got just another annoying pop-up:

<a href="window.close()"> back </a>

4) make sure all your JS is in a single line: breaks, returns and <br> can
cause JS errors
Randy.
Jul 23 '05 #7

P: n/a
On Thu, 9 Sep 2004 23:26:32 -0600, Randy <RP****@yahoo.com> wrote:

Sorry to berate you, but there are obvious errors here that you should
have found had you tested what you posted.
1) <a href="javascript: void();" onclick="window.open('new_window.htm',
'new_window','toolbar=no, status=no, menubar=no, resizeable=no')" > new
widow </a>
The feature string cannot contain spaces. It's also a bad idea to prevent
resizing (which you spelt incorrectly). Replace it with:

'resizable,scrollbars'

You should also avoid javascript URIs unless you have a *good* reason to
use them.

<a href="new_window.html" target="new_window"
onclick="window.open(this.href,this.target,'resiza ble,scrollbars');return
false;" new window</a> 2) then, in the new_window.htm -- a wee bit of JS:

<head>
<script language="javascript" type="text/javascript">
The language attribute is deprecated and shouldn't be used. The presence
of the type attribute also makes it unnecessary.
self-resizeTo(screen.width,screen.height);
self-moveTo(0,0);
That will cause an error, greatly annoy large or multi-monitor users, and
fail to work at all (assuming the dashes were dots) in all my browsers
except IE (which I only use to test, anyway).

[snip]
otherwise, you've got just another annoying pop-up:
All pop-ups are annoying, whether a close button is present or not.
<a href="window.close()"> back </a>


You certainly didn't test that.

[snip]

Please read the group FAQ (<URL:http://jibbering.com/faq/>), and test what
you post.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #8

P: n/a
Michael Winter wrote:
2) then, in the new_window.htm -- a wee bit of JS:

<head>
<script language="javascript" type="text/javascript">


The language attribute is deprecated and shouldn't be used. The presence
of the type attribute also makes it unnecessary.
self-resizeTo(screen.width,screen.height);
self-moveTo(0,0);


That will cause an error, greatly annoy large or multi-monitor users, and
fail to work at all (assuming the dashes were dots) in all my browsers
except IE (which I only use to test, anyway).


Even if it were written correctly, it still won't do anything in my browser,
where resizeTo() and moveTo() have no effect at all. Well, they have an
effect, when I realize the site author is trying to control the size and
position of my browser window, I chuckle a bit at my victory over their lame
attempt to enforce their will upon me.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #9

P: n/a
Randy wrote:
1) <a href="javascript: void();" onclick="window.open('new_window.htm',
'new_window','toolbar=no, status=no, menubar=no, resizeable=no')" > new
widow </a>
This is utter nonsense.

1. URIs must not contain whitespace, the ":" within the "href"
attribute value should not be followed by a space character.

2. "void" is a special operator, not a method; it requires an
operand that "()" does not provide. As the "click" event
is not canceled, this URI will cause a script error.

3. This link will not work if client-side scripting is absent;
either an error message from the UA will occur or just nothing
will happen.

4. The third argument of window.open() must not contain spaces,
so the features of the new window will not be applied here.
2) then, in the new_window.htm -- a wee bit of JS:

<head>
<script language="javascript" type="text/javascript">
self-resizeTo(screen.width,screen.height);
self-moveTo(0,0);
</script>
</head>
More nonsense.

1. Valid HTML requires a "title" element as child of the "head element.

2. The "language" attribute is deprecated. Using the required "type"
attribute value removes the need for using the former.

3. Object reference and method identifier are to be separated by the lookup
operator ".", not the substraction operator "-". Here, a substraction of
an object reference (self) by the *result* of the resizeTo() method will
be performed, resulting in a NaN (not a number) value that is discarded.
It only works because in many UAs, "self" is a reference to the current
Window object, which is also the global object;

resizeTo(screen.width,screen.height);
moveTo(0,0);

would also work and would avoid the useless operation.

4. Display resolution != desktop size != browser window size
!= viewport size. [psf 3.7]

5. Recent browsers allow these particular features of client-side
scripting to be disabled.
3) to provide the new window with an easy way out (other than the 'X'
Close in the upper right) provide for the use a <<back or <<home>> link
(which actually just closes the window, allowing the initial window to
re-appear); otherwise, you've got just another annoying pop-up:

<a href="window.close()"> back </a>
Nonsense. This link will do nothing, since there is not recource with
that URL (and can't be, see RFC 2396). The "href" attribute value must be
prefixed with "javascript:" or, even better, the "onclick" handler should
be used and the link should be written dynamically using DOM methods.
4) make sure all your JS is in a single line: breaks, returns and <br>
can cause JS errors


Nonsense. Understanding how automatic semicolon insertion works in
ECMAScript implementations and, even better, not to rely on it, helps to
understand why some code works and another does not. Basic knowledge on
how to use the debugging features of an UA also helps to find such errors.
Generally, there are no known errors to be caused by whitespace of any
kind within script code, which is in accordance to both the HTML 4.01 and
the ECMAScript Specification. Only in XHTML an attribute value should not
span several lines, so it is best to put script code in a single line if
it is used in an intrinsic event handler's attribute value; however,
maintenance efforts of complex statements usually decrease if they are
moved into a method and this method is called instead; this often removes
the need for several lines of code within the attribute value.

Please RTFM before posting more of such nonsense, thanks.
PointedEars
--
Don't throw houses when you live in a glass stone.
Jul 23 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.