Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell driver drivers email error ethernet excel firefox firefox 3 game hard drive internet internet explorer itunes laptop linux malware monitor network networking nvidia outlook outlook 2003 outlook 2007 outlook express partition printer problem router slow software sound trojan usb video virus vista windows windows vista windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: adding fallback to JS


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,188 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
04-Feb-2006, 05:08 PM #1
Solved: adding fallback to JS
I have a JavaScript fuction to open an image in a fixed sized popup window.

Whenever possible, I like to add "fallbacks" when using JS, incase the user doesn't have JS enabled in his/her browser or is using one that doesn't even support JS.

Right now the anchor part looks like this:
<a href='javascript:coins_enlarge()'>

Full anchor'd image:
<a href='javascript:coins_enlarge()'><img src='images/thumb_coins.gif' alt='Picture of coins' /></a>


Is there a way to change that so if the user doesm't have JS enabled it will just fallback to somethings like this
<a href='images/coins.gif'><img src='images/thumb_coins.gif' alt='Picture of coins' /></a>
But when JS is enabled it will open the fixed pixel window?
__________________
-----------------------------
| 404: Name Not Found |
-----------------------------
PLEASE NOTE: If I happen to help you in a post, or just simply reply to it, doesn't mean I want to be bombarded with PMs. I answer all questions in posts, not in PMs. Thank you, and have a good day.

<?php $h = 'Hello '; $w = 'World'; echo $h.$w; ?>

My Favorite Editors:
Windows: Crimson Editor
Mac: Taco HTML Edit
Linux: gPHPEdit
php guy's Avatar
Computer Specs
Senior Member with 514 posts.
 
Join Date: Dec 2004
Location: Bowlaro Lanes, WA
Experience: That's Mr. Clueless to you
04-Feb-2006, 10:10 PM #2
You could use <noscript> and JS's write to do this. Something like this:
Code:
<script type="text/javascript">
<!--
document.write('<a href="javascript:coins_enlarge()">');
//-->
</script>
<noscript><a href="images/coins.gif"></noscript>
<img src="images/thumb_coins.gif" alt="Picture of coins"  /></a>
That way, if they have JS, then it will write <a href="javascript:coins_enlarge()"> If they don't, then noscript will write the other link. Finally, <img src="images/thumb_coins.gif" alt="Picture of coins" /></a> is written for both cases.
__________________
if($post) echo $signature;
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,188 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
04-Feb-2006, 10:28 PM #3
Cool thanks
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:21 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.