Fmdpa Posted May 21, 2010 Share Posted May 21, 2010 How do I link to some HTML code, like having an external stylesheet, etc... I want to be able to change a certain section of code in one swoop for the all of the pages, instead of individually changing it on each page. Link to comment Share on other sites More sharing options...
dink Posted May 21, 2010 Share Posted May 21, 2010 How do I link to some HTML code, like having an external stylesheet, etc... I want to be able to change a certain section of code in one swoop for the all of the pages, instead of individually changing it on each page.A good place to start is the w3School tutorials.http://www.w3schools.com/css/css_howto.aspdink Link to comment Share on other sites More sharing options...
Ingolme Posted May 21, 2010 Share Posted May 21, 2010 You need to use a server-side language, such as PHP, to include HTML from another file.Here's a PHP example:<?php include 'file.html'; ?>But the code will only work if you have a server that can execute PHP. Link to comment Share on other sites More sharing options...
Fmdpa Posted May 21, 2010 Author Share Posted May 21, 2010 A good place to start is the w3School tutorials.http://www.w3schools.com/css/css_howto.aspdinkI know how to link to an external stylesheet. I was just using that as an example. Link to comment Share on other sites More sharing options...
Fmdpa Posted May 21, 2010 Author Share Posted May 21, 2010 You need to use a server-side language, such as PHP, to include HTML from another file.Here's a PHP example:<?php include 'file.html'; ?>But the code will only work if you have a server that can execute PHP.Thanks! Link to comment Share on other sites More sharing options...
dsonesuk Posted May 21, 2010 Share Posted May 21, 2010 Depends on the html code you want to include? you could try <object> to include menu code from one html document to to rest, which would save changing the menu in all these other documents.if you go this way use html without doctype (example below) WHY? because good ol IE will display an ugly outset, inset border if you use any of the doctype'sobjectnotframe.htm<html><head><style type="text/css">/*required css to hide scroll bars */body{overflow:hidden; }html {margin: 10px;overflow:auto;border: none;}</style></head><body><p>this is an object, not a frame. this is an object, not a frame.</p> </body></html>then use to below to show html code above.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title</head><body><object id="page" type="text/html" data="objectnotframe.htm" style="height:600px; width:500px;"> <p>Oops! That didn't work...</p> </object></body></html> Link to comment Share on other sites More sharing options...
Fmdpa Posted May 21, 2010 Author Share Posted May 21, 2010 Your example worked. Could I maybe just insert it as a txt file somehow as if it was actually IN the document, not as a separate HTML doc with the head, and all that? There will be scripts (functions) in the main page that are supposed to be executed on the inserted html. Basically, I want the linked doc to be read as part of the main document, instead of read separately then inserted. Link to comment Share on other sites More sharing options...
Synook Posted May 21, 2010 Share Posted May 21, 2010 You could, but you'd need to use a server-side language. Link to comment Share on other sites More sharing options...
Fmdpa Posted May 21, 2010 Author Share Posted May 21, 2010 Is that what "<?php include 'file.html'; ?>" would do? Link to comment Share on other sites More sharing options...
ShadowMage Posted May 21, 2010 Share Posted May 21, 2010 That's exactly what <?php include 'file.html'; ?> would do. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.