SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Evangelist fs_tigre's Avatar
    Join Date
    Feb 2009
    Location
    Close to Chicago, Illinois
    Posts
    517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I load an external file?

    Hi,

    Iím currently working on a web site where my client wants to be able to update the schedule page and what Iím thinking is to create an external file and then load it to my schedule page, this way it would be easier for him to make updates. I have done this before in flash using actionscript 3.0 but I just donít know how to do this in an HTML based page.

    What would be the easiest way to load an external file into a div or what would you guys recommend?

    Thanks,
    Fs_tigre

  2. #2
    SitePoint Evangelist kooshin.com's Avatar
    Join Date
    Dec 2003
    Location
    http://kooshin.com
    Posts
    505
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    perhaps you should use IIS or php includes

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With HTML you have two options: the deprecated iframe element or the object element (which is poorly supported by IE).

    It would be far better if you could use server-side includes as kooshin.com said.
    Birnam wood is come to Dunsinane

  4. #4
    SitePoint Evangelist fs_tigre's Avatar
    Join Date
    Feb 2009
    Location
    Close to Chicago, Illinois
    Posts
    517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would it be hard to do this using PHP?

  5. #5
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php include 'file.php'?>
    Should be relatively easy.
    Cross browser css bugs

    Dan Schulz you will be missed

  6. #6
    SitePoint Evangelist fs_tigre's Avatar
    Join Date
    Feb 2009
    Location
    Close to Chicago, Illinois
    Posts
    517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, the only thing I need to do is add this code where I want the file to be loaded? Does the file needs to be a php file?

    thanks

  7. #7
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It depends on how your server is setup, in reality you can have any file extension be it .php, .html, .ext to be processed as a PHP script. The .php extension is the safest and most consistent bet, however if the rest of all your files are .html ( if it was configured like this in the Apache config ) then it's best to be consistent. If you see '<?php' output with a .htm or .html extension that means it hasn't been setup, so either use .php or modify the configuration files.
    Cross browser css bugs

    Dan Schulz you will be missed

  8. #8
    SitePoint Zealot FaridHadi's Avatar
    Join Date
    Nov 2008
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can we have a look at the lay out of the schedule page and the data that needs to be dynamic? I'm guessing that just including a file isn't going to help too much unless your client knows HTML.

  9. #9
    SitePoint Addict
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    With HTML you have two options: the deprecated iframe element or the object element (which is poorly supported by IE).

    It would be far better if you could use server-side includes as kooshin.com said.
    But, there's a third solution for people who only have client side things:
    Let the other pages get loaded with some javascript (AJAX).

    Code and example is right here:
    http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    But keep in mind, the seo disadvantages are even st00pid as with frames/iframes.

  10. #10
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bulevardi View Post
    But, there's a third solution for people who only have client side things:
    Let the other pages get loaded with some javascript (AJAX).

    Code and example is right here:
    http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    But keep in mind, the seo disadvantages are even st00pid as with frames/iframes.

    Well, looking at the situation - the OP basically wants to seperate a page his client is updating so they don't interfere with his edits.

    AutisticCuckoo pointed out two HTML solutions - the frame which has the disadvantage of not being indexed by crawlers, and the object element which isn't practical because of the disadvantages of IE.

    The best solution which I agree with would be a server-side include, as this would be very reliable.

    Had the original poster mentioned that he wanted to pull in dynamic data, or bits and portions of something that is grabbed say, from a database such as maybe a month from a calendar to be displayed, something that is not meant to be static and something which comes in pieces, it would have been best to advise an XHR based solution so that the client wouldn't have the additional page refresh. In this situation, since the data is all static and is not residing in a database: in other words easily accessible it is best to not use an ajax based solution because it relies on a seperate behavior layer - Javascript and it wouldn't be indexed by crawlers either.
    Cross browser css bugs

    Dan Schulz you will be missed

  11. #11
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bulevardi View Post
    But, there's a third solution for people who only have client side things:
    Let the other pages get loaded with some javascript (AJAX).
    Yes, but since this was posted in the HTML and XHTML forum …

    Besides, that solution still requires a server-side component if you want to include content from another domain. At least until (if?) cross-domain XMLHttpRequest becomes available and widely supported.
    Birnam wood is come to Dunsinane

  12. #12
    SitePoint Evangelist fs_tigre's Avatar
    Join Date
    Feb 2009
    Location
    Close to Chicago, Illinois
    Posts
    517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you all for the good comments!


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
  •