WebDeveloper.com �: Where Web Developers and Designers Learn How to Build Web Sites, Program in Java and JavaScript, and More!   
Web Developer Resource Directory WebDev Jobs
Animated GIFs
CSS
CSS Properties
Database
Design
Flash
HTML
HTML 4.01 Tags
JavaScript
.NET
PHP
Reference
Security
Site Management
Video
XML/RSS
WD Forums
 Client-Side
  Development

    HTML
    XML
    CSS
    Graphics
    JavaScript
    ASP
    Multimedia
    Web Video
    Accessibility
    Dreamweaver
    General
    Accessibility
    Dreamweaver
    Expression Web

    General

 Server-Side
  Development

    PHP
    Perl
    .NET
    Forum, Blog, Wiki & CMS
    SQL
    Java
    Others

 Site Management
    Domain Names
    Search Engines
    Website Reviews

 Web Development
  Business Issues

    Business Matters

 Etc.
    The Coffee Lounge
    Computer Issues
    Feedback




DR. WEBSITE: Server Side Includes for Pulling Data; Linking to Framed Pages; Anchor References

By David Fiedler and Scott Clark

Dear Dr. Website®: Is there a way to pull info (e.g., a table full of data) from another Web page into the current page every time the current page is opened or refreshed?

The easiest way to do this is to use a Server Side Include (SSI). This would enable you to pull the info from one page into another page. People routinely do this for banner ads. The syntax varies from Web server to Web server, but generally it is as follows:

 <!--#include virtual="yourfile.html" --> 
where "virtual" is a URL relative to the directory containing the current document being processed. Then you could just create a Web page with nothing but the table full of data, and use an SSI to include that page on whatever page you wish. It will appear to the user to be one continuous page.

SSIs must be enabled on your server for this to work; try it on a test page, as SSIs are often enabled by default. Some Web servers require that a file with an SSI have an extension of .shtml, though most will work if you chmod the file to be executable:

 chmod 775 thisfile.html 
In addition, the following line should be used in the .htaccess file:
 AddType text/x-server-parsed-html .shtml 
That says any file with the .shtml extension may have SSI commands to be parsed. If you don't want to use a separate .shtml extension, you can change that to .html, but then all .html files will be checked for SSIs, slowing down the server to an extent.

Dear Dr. Website®: You mention in your FAQ how to link to a non-framed page from within a framed page, but how about the other way around?

If you want the framed page to appear within your own framed pages, you'd just link to it as you normally would and it will appear within your framed page. If you want it to take over the framed page, then you need to target it like this:

 <A HREF="newlink.html" TARGET="_top">this'll do it</A> 
That uses the "_top" target, which causes the browser to load the new framed page, assuming that newlink.html is a framed page, over the present page, framed or not.

Dear Dr. Website®: How would one reference an anchor within a page inside a frame? Would it require JavaScript?

Sometimes simplicity wins out, as it does in this case. No JavaScript is needed to accomplish this task--only standard HTML. Just use the pound sign, "#," at the end of the reference to the page containing the anchor, along with the name of the anchor:

 <A HREF="framedpage.html#thisanchor" TARGET="uptoyou"> this will take you to the anchor point</A> 
If you don't wish to target the anchor to a specific frame, you may omit the TARGET parameter; if you do wish to target a specific frame, include the TARGET parameter (as above), substituting your targeted frame's name for "uptoyou." If you wish to escape the frameset altogether, use the TARGET="_top" parameter, as we did in the second question above. Webdeveloper.com's Home Page


RELATED STORIES:

Keywords: html
Date: 19971117



HTML5 Development Center


Recent Articles