Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-24-2012, 02:05 AM   PM User | #1
MeltingDog
New to the CF scene

 
Join Date: May 2012
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
MeltingDog is an unknown quantity at this point
Best way to include an html file with JavaScript

Hi all,

I am trying to find a way to include a .html file in my client side only site (say for example: header.html).
Normally I would do this using PHP's include() function.

Is the best way to do this in JavaScript to create a .js file and have the html in a string and use <script> to bring it in?

Thanks!
MeltingDog is offline   Reply With Quote
Old 05-24-2012, 03:07 AM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,465
Thanks: 0
Thanked 499 Times in 491 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Since not everyone has JavaScript there is no way to add content to the page using JavaScript that will work for everyone.

You can embed an entire separate web page into HTML using an object tag (which replaced the old iframe tag back in 1997) in the HTML itself. Any HTML you add from JavaScript will only be seen by some visitors.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 05-24-2012, 07:14 AM   PM User | #3
MeltingDog
New to the CF scene

 
Join Date: May 2012
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
MeltingDog is an unknown quantity at this point
Quote:
Originally Posted by felgall View Post
Since not everyone has JavaScript there is no way to add content to the page using JavaScript that will work for everyone.

You can embed an entire separate web page into HTML using an object tag (which replaced the old iframe tag back in 1997) in the HTML itself. Any HTML you add from JavaScript will only be seen by some visitors.
Thanks Felgall,

Are you able to elaborate a little more?
MeltingDog is offline   Reply With Quote
Old 05-24-2012, 09:42 AM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,614
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Quote:
Originally Posted by MeltingDog View Post
Are you able to elaborate a little more?
http://joliclic.free.fr/html/object-tag/en/index.php
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Reply

Bookmarks

Tags
header, html, include, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:52 PM.


Advertisement
Log in to turn off these ads.