This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Dreamweaver > April 2004 > .net style switcher (with javascript)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
.net style switcher (with javascript)
|
|
| darrel 2004-04-21, 3:08 pm |
| I need some guidance as to whether or not my logic makes sense for this.
I'm building a .net style switcher for folks to be able to change the font
size on the page. I'd like to also have a javascript version (for those with
javascript) to save a server hit.
The logic would be this:
-check for cookie
-if there, grab value, link to the appropriate style sheet
-if not, write out the default cookie.
Then, the links for the actual switcher:
ahref="linktoself?fontsize=small" onclick="fontsize=small"
The logic being if there is javascript, the onclick will handle it. If not,
the page will reload with the value passed via the query string.
The question is what is the best way to handle the static link/page reload?
I like the query string method, but that can get messy, as we already are
using a handful of query strings. Plus, someone could (unlikely, but could)
resize a particular page, have the querystring sitting there, cut, paste,
and send to someone else, and thereby reset their preference for our site.
Maybe I'm worrying too much about that.
Alternatively, I suppose I could use a postback form, but how would that
work with the javascript there?
-Darrel
| |
| mzanime.com 2004-04-21, 3:09 pm |
| Very cool stuff for ASP developers.
I dunno much about .NET but I don't understand why you would want JS to handle
it instead if the user has JS enabled? Wouldn't .NET handling the entire thing
by itself, be better?
Here's a PHP way of doing it ( http://www.alistapart.com/articles/phpswitch/ )
if you haven't seen this already, and it worked like a charm for me.
| |
| darrel 2004-04-21, 3:09 pm |
| > I dunno much about .NET but I don't understand why you would want JS to
handle
> it instead if the user has JS enabled? Wouldn't .NET handling the entire
thing
> by itself, be better?
Javascript doesn't require a return to the server. .NET would require
another page request from the server. So, the idea is to let javascript
handle it if it's there, and, if not, then let the server process another
request. The javascript option is faster for the end-user and less load on
the server.
> Here's a PHP way of doing it (
http://www.alistapart.com/articles/phpswitch/ )
> if you haven't seen this already, and it worked like a charm for me.
Thanks, but PHP isn't going to do me much good on an IIS server. ;o)
-Darrel
| |
| mzanime.com 2004-04-21, 3:09 pm |
| darrel wrote:
>Thanks, but PHP isn't going to do me much good on an IIS server. ;o)
*cough* http://www.phpbuilder.com/columns/jayesh20021029.php3
I really don't think the JS wouldn't save -too- much time, as the server only
needs to parse a single line of code (and refresh the already cached page) ;-)
but you can do whatever you want.
| |
| darrel 2004-04-21, 3:09 pm |
| > >Thanks, but PHP isn't going to do me much good on an IIS server. ;o)
> *cough* http://www.phpbuilder.com/columns/jayesh20021029.php3
I'd love to convince the powers that be to use PHP, but it ain't gonna
happen. ;o)
> I really don't think the JS wouldn't save -too- much time, as the server
only
> needs to parse a single line of code (and refresh the already cached page)
;-)
> but you can do whatever you want.
It's perceived time. It is faster on the client end. Plus why hit the server
if you don't need to?
Also, wouldn't the new page be a 'new' page since it now has that one line
changed? IE, I don't think it'd cache, would it?
-Darrel
| |
| Al Sparber- PVII 2004-04-21, 3:09 pm |
| mzanime.com wrote:
> darrel wrote:
>
> *cough* http://www.phpbuilder.com/columns/jayesh20021029.php3
>
> I really don't think the JS wouldn't save -too- much time, as the
> server only needs to parse a single line of code (and refresh the
> already cached page) ;-) but you can do whatever you want.
It's still got to reload, cached or not. But if it's coded well, it's
only one time. Using JavaScript and the DOM would not require a reload
unless you wanted to support version 4 browsers and would be
instantaneous. But if someone is well-versed and comfortable in a server
technology, what the hell - go for it. It'll work for the handful of
non-developers who have JavaScript disabled.
--
Al Sparber - PVII
http://www.projectseven.com
Dreamweaver Extensions - DesignPacks - Tutorials - Books
---------------------------------------------------------------------
The PVII Newsgroup | news://forums.projectseven.com/pviiwebdev
The CSS Newsgroup | news://forums.projectseven.com/css
---------------------------------------------------------------------
| |
| mzanime.com 2004-04-21, 10:31 pm |
| Jeez you guys are so smart *shrinks* ._.
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|