Results 1 to 3 of 3

Thread: Ajax dynamically loading content into div

  1. #1
    Join Date
    Apr 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Ajax dynamically loading content into div

    Hi people,

    I am using this script http://www.dynamicdrive.com/dynamici...jaxcontent.htm to load html pages into a div on the index page.

    I have a navigation bar which has links the user can click on and the page loads into the div on the index page without the need for refreshing. This is my code:
    <nav id="firstNav">
    <ul>
    <li><a href="javascript:ajaxpage('page1.html','main'); loadobjs('styles/stylesheet.css')">ABOUT</a></li>
    </ul>
    </nav>

    The question is how would a user without javascript enabled open the page? I was thinking of having a html file for javascript users and non-javascript users, where the non-javascript pages would have the whole html file including head, navigation bar etc and so the page would have to reload, i tried to implement that but I didn't work. Is there a better way?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This would allow non-javascript users to at least see the page:

    Code:
    <nav id="firstNav">
    <ul>
    <li><a href="page1.html" onclick="ajaxpage(this.href,'main'); loadobjs('styles/stylesheet.css'); return false;">ABOUT</a></li>
    </ul>
    </nav>
    Or you could use a targeted iframe:

    Code:
    <nav id="firstNav">
    <ul>
    <li><a href="page1.html" onclick="ajaxpage(this.href,'main'); loadobjs('styles/stylesheet.css'); return false;" target="theiframe">ABOUT</a></li>
    </ul>
    </nav>
    Then in the main div have:

    Code:
    <div id="main">
    <noscript>
    <iframe name="theiframe" src="about:blank" width="100%" height="500" scrolling="auto" frameborder="0"></iframe>
    </noscript>
    </div>
    Then it would be almost the same for non-javascript users.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    legg92 (04-23-2014)

  4. #3
    Join Date
    Apr 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Appreciate it, thanks!

Similar Threads

  1. Replies: 1
    Last Post: 05-24-2009, 07:27 AM
  2. Loading Content into a Div Dynamically from an image link
    By John Michael Kinsella in forum Dynamic Drive scripts help
    Replies: 12
    Last Post: 05-13-2008, 08:51 PM
  3. Replies: 4
    Last Post: 02-11-2008, 02:38 PM
  4. Ajax Tab Content Script - dynamically changing tab content
    By core_dumped in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 08-24-2006, 07:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •