Results 1 to 8 of 8

Thread: HTML: Importing HTML from another file

  1. #1

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    HTML: Importing HTML from another file

    Is it possible, and if so how, to insert html into my html document like how this statement works for stylesheets??
    Code:
    <LINK href="StyleSheet.css" type="text/css" rel="stylesheet">
    The problem is I have a section of HTML code that is the same in every page and if I want to change it it would mean going thro every file and changing each file. My thort of the solution would be if I could put this repeated code in a seprate file then in all my other files I would put something like the satement above to import it.
    Any ideas??

    Thanx
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    To the best of my knowledge. The <LINK> Tag is largely ignored by most browsers with the exception of the CSS.

    With ASP you could just include the file but if you do not have ASP access, you might find the below exceptable for your needs.

    I use the following JavaScript method extensively on an Intranet I develope that has now server side access.

    Create your JavaScript File (MyHeader.js):

    Code:
    document.writeln("<table border=\"0\" cellspacing=\"4%\" cellpadding=\"5\">");
    document.writeln("<tr>");
    document.writeln("<td align=\"center\" bgcolor=\"#00D9FF\"><b><a href=\"http://www.RealisticGraphics.com\">Realistic Graphics</a></b></td>");
    document.writeln("<td align=\"center\" bgcolor=\"#00D9FF\"><b><a href=\"http://www.VBForums.com\">VBForums</a></b></td>");
    document.writeln("<td align=\"center\" bgcolor=\"#00D9FF\"><b><a href=\"http://www.google.com\">Google</a></b></td>");
    document.writeln("</tr>");
    document.writeln("</table>");
    document.writeln("<br>");
    Create your HTML File (MyPage.htm):

    Code:
    <script language="JavaScript" src="MyHeader.js"></script>
    Welcome to my JS Header Example.  The above HTML was imported to this page.
    Hope this helps.
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  3. #3

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Thanx, thats great!
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  4. #4
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    No problem, yell if you need anything else.
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  5. #5
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    what about IFRAMES
    Code:
    <iframe id="ifrmcontents" name="ifrmcontents" src="mypage.html" frameborder="0">

  6. #6
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    You could but it's not the same thing. Some versions of IE will display the iframe differently and some browsers won't display it at all.
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  7. #7
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    typical, that's the most annoying thing about web development.

  8. #8

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I had tried IFrames but the thing is I was trying to insert the HTML into a table and when I used IFrames it messed up the layout. No worries anyway its sorted now, mind I couldn't get it to work using .vbs/.vb files instead.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

Posting Permissions

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



Click Here to Expand Forum to Full Width