468,554 Members | 1,896 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,554 developers. It's quick & easy.

javascript alert problem

<script language="JavaScript">
!--
function onLoad()
{
if( self.innerWidth < 1024 )
{
self.moveTo( 0, 0 );
self.resizeTo( screen.availWidth, screen.availHeight );
}

if( self.innerWidth < 1024 )
{
alert( "This Web page was designed to be viewed using a" + " screen
resolution of 1024x768 or larger." );
}
}

Why thus code is not working when my screen resolution is 800*600? Please
Help!!

--
Thanks and Regards

Jorn
Jul 23 '05 #1
6 1886
Jorntk wrote on 04 mei 2004 in comp.lang.javascript:
<script language="JavaScript">
!--
function onLoad()
{
if( self.innerWidth < 1024 )
{
self.moveTo( 0, 0 );
self.resizeTo( screen.availWidth, screen.availHeight );
}

if( self.innerWidth < 1024 )
{
alert( "This Web page was designed to be viewed using a" + " screen
resolution of 1024x768 or larger." );
}
}


dit you try this [oonly this code in a html-file:

<body onload="alert(self.innerWidth)">

??

undefined

==================

Now try:

<body onload="alert(screen.availWidth)">

See:
<http://msdn.microsoft.com/workshop/
author/dhtml/reference/dhtml_reference_entry.asp>

and perhaps also:
<http://msdn.microsoft.com/workshop/author/om/measuring.asp>

because client users more often than not do not want full screen

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #2
Ok, it work now. But i got new problem.
I put the alert in a header.php where i will call the header.php everytime.
This cause the alert pop up when I click every button to view new page.
So, is there anyway to limit the alert to only pop up for one time??
Please advice. Thanx!
Jul 23 '05 #3
Ivo
"Jorntk" wrote
Ok, it work now. But i got new problem.
I put the alert in a header.php where i will call the header.php everytime. This cause the alert pop up when I click every button to view new page.
So, is there anyway to limit the alert to only pop up for one time??
Please advice. Thanx!


The usual way to do this is with a cookie or something serverside like a
session variable. There is no other way of knowing the difference between
first time visitors and those going to the next page.
But also to be considered: There might be a lot people going to the next
page if you leave it up to them to resize their window. And unless you have
something very special to show, you should not design for any specific
screen resolution at all. Most users do not even know how to change their
resolution (assuming, against better judgement, they would be willing to go
through of trouble of doing so only to see your site) so the javascript will
do nothing but annoy people.
HTH
Ivo
Jul 23 '05 #4
On Tue, 4 May 2004 19:13:33 -0700, Jorntk <jo****@yahoo.com> wrote:
Ok, it work now. But i got new problem.
I put the alert in a header.php where i will call the header.php
everytime.
This cause the alert pop up when I click every button to view new page.
So, is there anyway to limit the alert to only pop up for one time??
Please advice. Thanx!


Frankly, you shouldn't do it at any time. The users don't know or care
what it was designed for. After all, their resolution will, more than
likely, be set to the optimal value anyway, so what good will it do? Sites
for the World Wide Web should use liquid design so it doesn't matter
(within reason) what the resolution is, large or small. Finally, screen
resolution means practially nothing. It's set to 1024x768 on this machine,
but you'll only get 866x582 to work with once you remove toolbars,
sidebars, and the like.

One final point, you do realise that statistics (unreliable as they are)
show the majority of users use 800x600, don't you?

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #5
In article <40********@news.tm.net.my>, jo****@yahoo.com enlightened us
with...
<script language="JavaScript">
!--
function onLoad()
{
if( self.innerWidth < 1024 )
{
self.moveTo( 0, 0 );
self.resizeTo( screen.availWidth, screen.availHeight );
Um, you do know that us Opera and Mozilla users can disable that
nonsense, right?
You have no right to resize or move MY windows. Sorry.
}

if( self.innerWidth < 1024 )
{
alert( "This Web page was designed to be viewed using a" + " screen
resolution of 1024x768 or larger." );


I guess I won't be using your page. Neither will most people. The
majority of users use 800 by 600. And an alert? How annoying. I can
read. If you want to tell people that you can't code, just put it on the
page.

Gee, I sure hope disabled people don't need your site, either.

--
--
~kaeli~
A hangover is the wrath of grapes.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #6
Jorntk wrote:
Ok, it work now. But i got new problem.
I put the alert in a header.php where i will call the header.php everytime.
This cause the alert pop up when I click every button to view new page.
So, is there anyway to limit the alert to only pop up for one time??
Please advice. Thanx!


You only think you have it working. For starters, "self.innerWidth" returns
"undefined" on Internet Explorer, which is always less then 1024 on Internet
Explorer.

On browsers like Gecko based browsers (Netscape 7.1, Mozilla, Firefox, Camino,
Opera 7.23), where self.innerWidth actually returns typeof "number", even a
user with a 1024 x 768 desktop will be told they aren't running their browser
at 1024 x 768, because window.innerWidth is ALWAYS less then the width of the
applicable desktop (due to borders and scrollbars and any side-docked
toolbars).

Not to mention that in Netscape 7.1, Mozilla and Firefox, browsers where you
are actually able to retrieve self.innerWidth (and make an incorrect assumption
about the size of their browser based on that value), users can disable the
ability for you to move or resize their browser.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by elsenraat_76 | last post: by
7 posts views Thread by e | last post: by
6 posts views Thread by Steve B. | last post: by
7 posts views Thread by C.Joseph Drayton | last post: by
16 posts views Thread by Tony Girgenti | last post: by
9 posts views Thread by Matthew Wells | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.