include file using html

liunx

Guest
I have been using include file for consistency purpose but I need to use asp file as extension because when I tried using htm as extension, it doesn't work. So, my question is any way to have these 'include' file in htm. Meaning that, for example 3 file have same header, these 3 file just link to one file called inc_header.htm. Hope you guys understand. Thanks in advance for any idea or advice.:rolleyes:<!--content-->all depends on how you are including these files??<!--content-->I write all my files in HTML but save them as .asp as this makes no real difference when viewing in a browser. The includes should really be saved as a .inc file. Here is an example of how I do it.<br />
<br />
<html><br />
<head><br />
<title>Ent Imp - The Entertainment Imperium.</title><br />
<meta name="title" content="Ent Imp Dot Com - The Movie and Entertainment Portal."><br />
<br />
<!--#include virtual="meta.inc" --><br />
<br />
</head><br />
<br />
<body bgcolor="#FFFFFF" text="#000000"><br />
<br />
<!--#include virtual="nav.inc" --><br />
<br />
</body><br />
</html><br />
<br />
The files is saved as index.asp though written no differently from HTML, the incldes written in normal html markup and saved as .inc, I hope that ade some kinda sense.<!--content-->actuall entimp, that is very bad practice. by saving it as an asp page it is telling the server that it is serverside language and to go ahead and parse it as such. if you don't use asp in it, then you might have problems with with server load and such. ABIET a small issue but none-the-less you shouldn't be doing that.<br />
<br />
also it is a bad idea to name your includes as .inc. I know on the php side a *.inc file will not be parsed by the server as a serverside language and so it may lead to some users just typing in the name.inc and looking at the contents. as you can see if you had some vital info in that file then they just looked at it. all in all it doesn't matter waht extension you use to include with.<!--content-->Ok here we go again Mr Scoutt... Looks like we can argue this one for a while.<br />
<br />
Other than including the declaration of:<br />
<%@ language="vbscript" %><br />
before<br />
<html><br />
<br />
the way to go is to write the page in html and declare it as html as this is what asp is intended for to a major extent. ASP is a language to dynamically interface with data on a given server and return results back as HTML. .asp actually indicate that the file is written in HTML with on occassion, not always, some vbscript scripting.<!--content-->ps<br />
<br />
.inc is the a standard and acceptable way of suffixing asp include files.<!--content-->ok so tell me if you named your html page .html adn added ASP to that page and still kept it as html, do you think the server will parse it as ASP or html.....<br />
<br />
it will show all the asp you put into it and the html will run ok. by naming a page with a asp extension tells the server to parse it like asp not html. hence if the server sees the html it will not parse it as serverside langauge. why do you think you should use shtml? it tell the server that there is serverside includes in this document and should be parsed as such, not plain html. it doesn't take a server to run html, but it takes it to run serverside language. by telling the server you have asp as the extension it is making the server work twice as hard as it would not normally do it if was just plain html. <br />
<br />
do you understand that :P<!--content-->Originally posted by entimp <br />
ps<br />
<br />
.inc is the a standard and acceptable way of suffixing asp include files. <br />
I agree, but for security reason you shouldn't do it like that.<!--content-->If you asp in a .html document that is perfectly valid... all you do is declare that there is some vbscript in the page with the correct language declaration. This works fine. By telling the server it is ASP you are telling it that the page is HTML on the front end.<br />
<br />
As for the argument regarding SHTML I can't argue too well as SHTML is a complete mystery to me at the moment. As for ASP, the protocols were created to return data as html and thus the source cannot be read in full. The source you can read is the returned document that will always open as <html> with none of the VBscript language in it or the addresses for the includes.<br />
<br />
Take this page for example.<br />
<!-- m --><a class="postlink" href="http://www.entimp.com/calender/diary.asp?view_date=01-November-2002">http://www.entimp.com/calender/diary.as ... ember-2002</a><!-- m --><br />
Try and view the ASP modules, you cant and I challenge you to do so... you will also notice the page returns the source in nothing but plain ole HTML but the file is a .asp file.<br />
<br />
As for security reasons you can't read the full address of the include unless you write the page wrong, and that would go for any language that I know of.<!--content-->your missing the point here entimp. if you use asp in a html page it will not render. if you use vbscript (client side asp) then it will render as html. maybe I don't fully understand ASP but in php if you have an include as a *.inc and some person knws about this file, all they have to type is you page.inc in the address bar and view whatever is in that file. WHY, that is because the server doesn't know that inc is a serverside page and should be processed as such. the server doesn't care if it doesn't have anyhting to do with serverside language it will run it as plain html page, thus showing all your info in this file as you have coded it. now it deosn't have nothing to do with how you coded it but the being the file as the wrong extension.<br />
<br />
now that I just explained that you can see where I am coming from as I would suspect all serverside langauge should react the same.<br />
<br />
but in all fairness if you use<br />
<!--#include virtual="nav.inc" --><br />
<br />
the sever will parse it as a shtml file instead.<!--content-->I'm off to work but will come back to this in the morning... we are both right in some respects, will clarify later.<!--content-->well, after hearing both of you all making your own stand, I would like to go back to my question. If I don't want to use *.asp as scoutt you said that is not a good way to do it, how should I do it? How do I include include file in html? Is that possible? If not, what would be other ways?<!--content-->sorry ngaisteve1, we get carried away sometimes. :P<br />
<br />
if you want to include files you have to use shtml or the javascript way. <br />
<br />
<script src=http://www.htmlforums.com/archive/index.php/"page.html"></script><br />
<br />
I beleive it is something like that, been awhile since I used it<!--content-->It's ok with that. Yeah, I tried the way you taught me but it doesn't work. So, I tried to validate it in <!-- m --><a class="postlink" href="http://validator.w3.org/">http://validator.w3.org/</a><!-- m -->. I posted my code here, <!-- m --><a class="postlink" href="http://www.citylinkexpress.com/malaysia/test.html">http://www.citylinkexpress.com/malaysia/test.html</a><!-- m -->. So, what's wrong here and solution for it? Tx.:)<!--content-->i just tried the URL to your test page, but got a 404 error (no page).<br />
<br />
<br />
i'm with Scoutt on the PHP/ASP parsing. I use IIS, and I have to tell which extensions are to be parsed through the PHP pre-processor software. I suppose you could tell the server to pass .inc files through the ASP pre-processor (does it work like that?) too.<!--content-->I am sorry hondrous. Perhaps, I tested it locally. Now, it is uploaded.<!--content-->nope, still can't see it.<!--content-->In Scoutt reply, he mentioned "if you want to include files you have to use shtml or the javascript way. <br />
<br />
<script src=http://www.htmlforums.com/archive/index.php/"page.html"></script>"<br />
<br />
I follow that, look at my code. But, dooesn't work. In my page.html got message testing. if you can see. hurray! . But, since I can't see it, it means that scoutt's way doesn't work. So, what should I do?<!--content-->i am still getting a 404 error - file not found - from your link<!--content--><script src=http://www.htmlforums.com/archive/index.php/"page.html"></script><br />
<br />
This should, of course, be:<br />
<br />
<script src=http://www.htmlforums.com/archive/index.php/"page.html" type="text/javascript" language="javascript"></script><br />
<br />
Mutter.. mumble.. darn validator..<br />
<br />
<br />
<edit>Just as I hit the [submit] button I spotted the .html extension in the example, then my computer locked up. It then took ages to find this thread again. Hmm, let me revise that:<br />
<br />
For javascript code, you'll need:<br />
<script src=http://www.htmlforums.com/archive/index.php/"page.js" type="text/javascript" language="javascript"></script><br />
<br />
For HTML includes, I'm not sure if this a valid way or not.</edit><!--content-->no, it won't giz, the html file has nothing to do with javascript. it will only be html and that is it. it is one of those things you have to let go, like marginheight :)<br />
<br />
Horus, he has a period on the end of the url.<br />
<br />
what is in the page.html??<!--content-->page.html got this message testing. if you can see. hurray!. You may try it <!-- m --><a class="postlink" href="http://www.citylinkexpress.com/malaysia/page.html">http://www.citylinkexpress.com/malaysia/page.html</a><!-- m --><br />
<br />
So, what extention should I use for include file *.js or *.html?<!--content-->Im not sure if you have this one figured out yet but what works for me is naming your main file *.shtml and naming your include with a *.htm extension. im not sure if this is kosher but it works for me. as for how to "call" the include into the file i use:<br />
<br />
<!--#include file="thefilename.htm"--><!--content-->
 
Back
Top