That seems like it would work nicely, but doesn't it pretty much
negate the gracefulness of using Ajax to insert content into a DIV
(the grace that allowed me to stop maintaining clumsy header.php,
footer.php, navbar.php, etc, and piecing together based on the user-
agent type)?

On Sep 11, 3:41 pm, Ken Snyder <[EMAIL PROTECTED]> wrote:
> Dustin S wrote:
> > I've got a homepage right now with a few links that each use an
> > Ajax.Updater to XHR-in some content that gets shoved into the middle
> > of my page. I'm wondering how to gracefully handle two things:
> > (1) Users with normal browsers (i.e. JavaScript capable) who want to
> > direct link to some content on my page,
> > (2) How to properly handle non-JS browsers and still allow them to be
> > able to see the content as well.
> > The "web 2.0" solution I've had so many people try to sell to me so
> > far is to use careful "display:none;" and "show/hide" combinations to
> > just show and hide my content, with it all actually on my page. This
> > would mean I'm not XHRing the stuff in from somewhere else, though,
> > and the end result is an extremely heavyweight page (unacceptable).
> > -d
> We were just discussing this type of unobtrusiveness in the office.  :)
> For your case, you may want to consider using frames or an iframe. If
> your system gets any more complicated or you want to do something like
> modal windows, the following approach works well:
> <div id="middlePageContent"></div>
> <a href="page/with/content.php" class="ajax">View some content</a>
> <script>
> $$('a.ajax').invoke('observe', 'click', function(event) {
>   var element = event.element();
>   var url = element.href + (element.href.indexOf('?') > -1 : '&' : '?')
> + 'ajax=1';
>   new Ajax.Updater('middlePageContent', url);
>   event.stop();});
> </script>
> page/with/content.php:
> <?php
> //..
> if ($_REQUEST['ajax'] != 1) include 'htmlHeader.php';
> echo $pageContent;
> if ($_REQUEST['ajax'] != 1) include 'htmlFooter.php';
> ?>
> You basically code the pages to work without JavaScript, but then
> observe each <a> with a certain class. The observer stops the default
> action (going to the page) and runs an Ajax.Updater request.  The server
> side page then just needs to skip output of the html header and footer
> if the request is from an XMLHttpRequest.
> - Ken Snyder
You received this message because you are subscribed to the Google Groups 
"Prototype &" group.
To post to this group, send email to
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to