To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Misc Help > ClientSide Technologies

ClientSide Technologies Discuss HTML/CSS/Javascript, and any other client-side technologies, here.

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-11-2006, 09:53 PM   #1
Samo
The Graphics Kid
 
Join Date: Mar 2006
Posts: 21
If/Else Question

i'm just about ready to start my first javascript project, but there's one thing i need to know before i do it.

is it possible to make and if/else statement where if the else part is the active part that the javascript will exit and go into regular html mode so that in the 20% or so chance cae that the user has js disabled, they'll still be able to see the site? and if so, if the if part is the active part, will it do that and then the regular html part or just the if part?

Last edited by Samo; 03-11-2006 at 10:27 PM.
Samo is offline   Reply With Quote
Old 03-12-2006, 12:07 AM   #2
bradgrafelman
Pna lbh ernq guvf?
 
Join Date: Jul 2004
Location: 40.566N -89.731W, ~469ft above sea level
Posts: 11,488
I'm really trying to understand what you're saying... honestly... but I can't.

You mentioned "if the user has JS disabled". If they have it disabled, the entire script won't do a single thing. Instead, you might look at using NOSCRIPT tags.
__________________
***If your problem has been solved, PLEASE click the RESOLVED LINK under "Thread Tools"***

"Well Bones, do the new medical facilities meet with your approval?" -- Kirk
"They do not. It's like working in a damn computer center" -- McCoy (Star Trek: TMP)

Useful links: Debugging 101 || NJOE || (Sig image) || Rolla Engineered Solutions, LLC
bradgrafelman is offline   Reply With Quote
Old 03-12-2006, 12:17 AM   #3
Samo
The Graphics Kid
 
Join Date: Mar 2006
Posts: 21
read post #3 for explaination

and then post #7 if u understand
Samo is offline   Reply With Quote
Old 03-12-2006, 02:20 AM   #4
Weedpacket
Custom User Title™
 
Weedpacket's Avatar
 
Join Date: Aug 2002
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,128
bradgrafelman has already given you your answer.
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
Weedpacket is offline   Reply With Quote
Old 03-12-2006, 08:41 AM   #5
madwormer2
Cardboard box 2.4
 
madwormer2's Avatar
 
Join Date: Apr 2005
Location: UK
Posts: 691
Yeh, you seem to believe that if javascript is disabled... it'll run the javascript else statement.

But it wont... because if javascript is disabled, it'll just skip over it completely.
madwormer2 is offline   Reply With Quote
Old 03-12-2006, 09:58 AM   #6
JPnyc
Administrator
 
Join Date: Jan 2005
Posts: 963
The way one deals with this is, you create a regular HTML version of the site that includes a javascript redirect to the javascript version. If they have it disabled, they see the HTML version since the redirect will do nothing. And obviously if they have it enabled they'll be redirected to the JS version
__________________
PHP builder Online Community Manager

JPnyc is offline   Reply With Quote
Old 03-12-2006, 12:32 PM   #7
dream.scape
Senior Member
 
dream.scape's Avatar
 
Join Date: Jan 2006
Posts: 204
use the noscript tag to catch people with javascript disabled if you want to display something different to them.

HTML Code:
<script type="text/javascript">
//<![CDATA[
	document.write('<p>You have javascript enabled<\/p>');
//]]>
</script>
<noscript>
	<p>You have havascript disabled</p>
</noscript>
dream.scape is offline   Reply With Quote
Old 03-12-2006, 02:35 PM   #8
JPnyc
Administrator
 
Join Date: Jan 2005
Posts: 963
Bit cumbersome if he wants to code an entire JS free version of the site though. Means longer load time for everyone, if the page is complex and has a fair amount of code.
__________________
PHP builder Online Community Manager

JPnyc is offline   Reply With Quote
Old 03-12-2006, 04:00 PM   #9
dream.scape
Senior Member
 
dream.scape's Avatar
 
Join Date: Jan 2006
Posts: 204
Quote:
Originally Posted by JPnyc
Bit cumbersome if he wants to code an entire JS free version of the site though. Means longer load time for everyone, if the page is complex and has a fair amount of code.
Seeing as though he's been extremely vague on what he wants to do, I thought I'd put it out there.
dream.scape is offline   Reply With Quote
Old 03-12-2006, 04:47 PM   #10
JPnyc
Administrator
 
Join Date: Jan 2005
Posts: 963
Agreed.
__________________
PHP builder Online Community Manager

JPnyc is offline   Reply With Quote
Old 03-12-2006, 06:30 PM   #11
Samo
The Graphics Kid
 
Join Date: Mar 2006
Posts: 21
ok, here's is what i'm trying to do, i'm trying to make it so that if your screen res is smaller than 1024x768, a lower res version will be displyed AUTOMATICALLY

no here's the thing, i can make it so that if the user has javascript disabled, they will just get the regular, pure html 1024x768 version. that's the easy part. the problem is, i don't know if it's possible so that if js is enabled, they will only get the version that corresponds with their screen res instead of both tables
Samo is offline   Reply With Quote
Old 03-12-2006, 07:03 PM   #12
JPnyc
Administrator
 
Join Date: Jan 2005
Posts: 963
Using the method I mentioned, you can. Put the screen width detect script with a redirect into the 1024 version. If they dont have JS enabled, it will do nothing and they'll just get the 1024 version.
__________________
PHP builder Online Community Manager

JPnyc is offline   Reply With Quote
Old 03-12-2006, 07:03 PM   #13
JPnyc
Administrator
 
Join Date: Jan 2005
Posts: 963
But why not just make the table width a % value? Doesn't that take care of it with no procedural coding?
__________________
PHP builder Online Community Manager

JPnyc is offline   Reply With Quote
Old 03-12-2006, 09:03 PM   #14
Samo
The Graphics Kid
 
Join Date: Mar 2006
Posts: 21
yes, but then for any res larger than 1024, the images will be distorted. the page is graphical, not tables and colors

i would do ur idea, but i really want this to be 100% automatic. or, wait, r u saying that i make 2 versions of each page, and the js will automatically redirect to the % page?
Samo is offline   Reply With Quote
Old 03-12-2006, 10:22 PM   #15
JPnyc
Administrator
 
Join Date: Jan 2005
Posts: 963
Could do that, or you could use a JS function to change the images and table size if they have JS enabled and the res is a certain size. Whichever way you think is easier
__________________
PHP builder Online Community Manager

JPnyc is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 06:01 AM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.