Connecting Tech Pros Worldwide Forums | Help | Site Map

javascript alert problem

Jorntk
Guest
 
Posts: n/a
#1: Jul 23 '05
<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



Evertjan.
Guest
 
Posts: n/a
#2: Jul 23 '05

re: javascript alert problem


Jorntk wrote on 04 mei 2004 in comp.lang.javascript:
[color=blue]
> <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." );
> }
>}
>[/color]

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)
Jorntk
Guest
 
Posts: n/a
#3: Jul 23 '05

re: javascript alert problem


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!


Ivo
Guest
 
Posts: n/a
#4: Jul 23 '05

re: javascript alert problem


"Jorntk" wrote[color=blue]
> Ok, it work now. But i got new problem.
> I put the alert in a header.php where i will call the header.php[/color]
everytime.[color=blue]
> 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![/color]

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


Michael Winter
Guest
 
Posts: n/a
#5: Jul 23 '05

re: javascript alert problem


On Tue, 4 May 2004 19:13:33 -0700, Jorntk <jorntk@yahoo.com> wrote:
[color=blue]
> 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![/color]

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.Winter@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
kaeli
Guest
 
Posts: n/a
#6: Jul 23 '05

re: javascript alert problem


In article <40974c4c_1@news.tm.net.my>, jorntk@yahoo.com enlightened us
with...[color=blue]
> <script language="JavaScript">
> !--
> function onLoad()
> {
> if( self.innerWidth < 1024 )
> {
> self.moveTo( 0, 0 );
> self.resizeTo( screen.availWidth, screen.availHeight );[/color]

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.
[color=blue]
> }
>
> if( self.innerWidth < 1024 )
> {
> alert( "This Web page was designed to be viewed using a" + " screen
> resolution of 1024x768 or larger." );[/color]

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

Grant Wagner
Guest
 
Posts: n/a
#7: Jul 23 '05

re: javascript alert problem


Jorntk wrote:
[color=blue]
> 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![/color]

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 <gwagner@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


Closed Thread