Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Simple html include?

Reply
Thread Tools

Simple html include?

 
 
Crappola 308
Guest
Posts: n/a
 
      02-12-2011
Hi everyone,

I have a small problem with my web site and though I'd ask here first. I suspect
it's a fairly common problem, now that I read a bit about it.

All my pages are .html 4.01 pages. Every page on my site has 4 scripts. A js for
StatCounter which counts visitors, a js for a small widget which shows online
visitors, some regular html code for the valid HTML 4.01 tag (that's not
actually js, but the usual html validation referrer code for W3) and a js for
Google analytics. The scripts are distributed like this. Google wants their
script just before </head>.

<html>
<head>
..css
google.js
</head>

<body>
....
statcounter.js
widget.js
w3.html
</body>

I was thinking that maybe it would be a good idea to "extract" all those pieces
of code, put them all in some higher directory and load them dynamically as
includes on every page. I am basically cluless on html, so I searched the net
and found that there are several solutions to this.

The easier seems to be Server Side Includes (SSI), using something like:

<html>
<head>
..css
<--#include virtual="http://www.xxx.com/js/google.html"--->
</head>
<body>
....
<--#include virtual="http://www.xxx.com/js/statcounter.html"--->
<--#include virtual="http://www.xxx.com/js/widget.html"--->
<--#include virtual="http://www.xxx.com/js/w3.html"--->
</body>

It looks elegant, too. BUT: In order to do this, I have to do either:

include a .htaccess file which enables SSI on my domain provider (yahoo
webhosting) for my directories. I tried uploading one such file to my main web
hosting directory, but I got a message saying something like "forbidden, stay in
your directory only". So this is out.

Second solution: Assuming the yahoo host activates SSI with .shhtp (some servers
do?) I could conceivably change all my pages to .shttp, but this is no go,
because the web site has over 250 pages with many links already hardcoded
outside my site. Also, I tried it on one page and it doesn't work. Solutions
which will force me to change the page type are out.

..php solutions also require me to change the type of web pages, so these are
out.

I also tried the following pseudo-include:

<script type="text/javascript"
src="http://www.xxx.com/js/statcounter.html"></script>

Doesn't work either.

The yahoo hosting representatives are fairly clueless about all this. I just
need a simple html include, to eliminate around 250 repeated instances of the
same quadruple code on my web site. Nothing more, nothing less.

Is there a solution for this or am I searching in vain?

Thanks

 
Reply With Quote
 
 
 
 
richard
Guest
Posts: n/a
 
      02-13-2011
On Sun, 13 Feb 2011 01:44:00 +0200, Crappola 308 wrote:

> Hi everyone,
>
> I have a small problem with my web site and though I'd ask here first. I suspect
> it's a fairly common problem, now that I read a bit about it.
>
> All my pages are .html 4.01 pages. Every page on my site has 4 scripts. A js for
> StatCounter which counts visitors, a js for a small widget which shows online
> visitors, some regular html code for the valid HTML 4.01 tag (that's not
> actually js, but the usual html validation referrer code for W3) and a js for
> Google analytics. The scripts are distributed like this. Google wants their
> script just before </head>.
>
> <html>
> <head>
> .css
> google.js
> </head>
>
> <body>
> ...
> statcounter.js
> widget.js
> w3.html
> </body>
>
> I was thinking that maybe it would be a good idea to "extract" all those pieces
> of code, put them all in some higher directory and load them dynamically as
> includes on every page. I am basically cluless on html, so I searched the net
> and found that there are several solutions to this.
>
> The easier seems to be Server Side Includes (SSI), using something like:
>
> <html>
> <head>
> .css
> <--#include virtual="http://www.xxx.com/js/google.html"--->
> </head>
> <body>
> ...
> <--#include virtual="http://www.xxx.com/js/statcounter.html"--->
> <--#include virtual="http://www.xxx.com/js/widget.html"--->
> <--#include virtual="http://www.xxx.com/js/w3.html"--->
> </body>
>
> It looks elegant, too. BUT: In order to do this, I have to do either:
>
> include a .htaccess file which enables SSI on my domain provider (yahoo
> webhosting) for my directories. I tried uploading one such file to my main web
> hosting directory, but I got a message saying something like "forbidden, stay in
> your directory only". So this is out.
>
> Second solution: Assuming the yahoo host activates SSI with .shhtp (some servers
> do?) I could conceivably change all my pages to .shttp, but this is no go,
> because the web site has over 250 pages with many links already hardcoded
> outside my site. Also, I tried it on one page and it doesn't work. Solutions
> which will force me to change the page type are out.
>
> .php solutions also require me to change the type of web pages, so these are
> out.
>
> I also tried the following pseudo-include:
>
> <script type="text/javascript"
> src="http://www.xxx.com/js/statcounter.html"></script>
>
> Doesn't work either.
>
> The yahoo hosting representatives are fairly clueless about all this. I just
> need a simple html include, to eliminate around 250 repeated instances of the
> same quadruple code on my web site. Nothing more, nothing less.
>
> Is there a solution for this or am I searching in vain?
>
> Thanks


Have you looked at perhaps using the <link> tag?
 
Reply With Quote
 
 
 
 
richard
Guest
Posts: n/a
 
      02-13-2011
On Sun, 13 Feb 2011 01:44:00 +0200, Crappola 308 wrote:

> Hi everyone,
>
> I have a small problem with my web site and though I'd ask here first. I suspect
> it's a fairly common problem, now that I read a bit about it.
>
> All my pages are .html 4.01 pages. Every page on my site has 4 scripts. A js for
> StatCounter which counts visitors, a js for a small widget which shows online
> visitors, some regular html code for the valid HTML 4.01 tag (that's not
> actually js, but the usual html validation referrer code for W3) and a js for
> Google analytics. The scripts are distributed like this. Google wants their
> script just before </head>.
>
> <html>
> <head>
> .css
> google.js
> </head>
>
> <body>
> ...
> statcounter.js
> widget.js
> w3.html
> </body>
>
> I was thinking that maybe it would be a good idea to "extract" all those pieces
> of code, put them all in some higher directory and load them dynamically as
> includes on every page. I am basically cluless on html, so I searched the net
> and found that there are several solutions to this.
>
> The easier seems to be Server Side Includes (SSI), using something like:
>
> <html>
> <head>
> .css
> <--#include virtual="http://www.xxx.com/js/google.html"--->
> </head>
> <body>
> ...
> <--#include virtual="http://www.xxx.com/js/statcounter.html"--->
> <--#include virtual="http://www.xxx.com/js/widget.html"--->
> <--#include virtual="http://www.xxx.com/js/w3.html"--->
> </body>
>
> It looks elegant, too. BUT: In order to do this, I have to do either:
>
> include a .htaccess file which enables SSI on my domain provider (yahoo
> webhosting) for my directories. I tried uploading one such file to my main web
> hosting directory, but I got a message saying something like "forbidden, stay in
> your directory only". So this is out.
>
> Second solution: Assuming the yahoo host activates SSI with .shhtp (some servers
> do?) I could conceivably change all my pages to .shttp, but this is no go,
> because the web site has over 250 pages with many links already hardcoded
> outside my site. Also, I tried it on one page and it doesn't work. Solutions
> which will force me to change the page type are out.
>
> .php solutions also require me to change the type of web pages, so these are
> out.
>
> I also tried the following pseudo-include:
>
> <script type="text/javascript"
> src="http://www.xxx.com/js/statcounter.html"></script>
>
> Doesn't work either.
>
> The yahoo hosting representatives are fairly clueless about all this. I just
> need a simple html include, to eliminate around 250 repeated instances of the
> same quadruple code on my web site. Nothing more, nothing less.
>
> Is there a solution for this or am I searching in vain?
>
> Thanks


BTW, to use the php stuff, it is necessary that you have php on the server.
Then you must name the files as "php" not html.
 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      02-13-2011
richard wrote:

> BTW, to use the php stuff, it is necessary that you have php on the server.


True.

> Then you must name the files as "php" not html.


Not true. Server setup dependent. Also the files could be named with
extension '.php' with the URL having the "extension" '.html'. There are
several ways to accomplish that.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
Crappola 308
Guest
Posts: n/a
 
      02-13-2011
Sherm Pendley wrote:
> "Crappola 308" <(E-Mail Removed)> writes:
>
>> It looks elegant, too. BUT: In order to do this, I have to do either:
>>
>> include a .htaccess file which enables SSI on my domain provider
>> (yahoo webhosting) for my directories. I tried uploading one such
>> file to my main web hosting directory, but I got a message saying
>> something like "forbidden, stay in your directory only".

>
> That message strongly implies that you were *not*, in fact, trying to
> upload to your own web hosting space.
>
> sherm--


The yahoo web hosting server won't allow me to upload a file named like that
(.htaccess). Says, "invalid file name". If I upload it named x.htaccess for
example and then try to rename, it won't let me rename it. Says "illegal file
name".

 
Reply With Quote
 
Adrienne Boswell
Guest
Posts: n/a
 
      02-13-2011
Gazing into my crystal ball I observed "Jonathan N. Little"
<(E-Mail Removed)> writing in
news:ij7ao5$drt$(E-Mail Removed)-september.org:

> richard wrote:
>
>> BTW, to use the php stuff, it is necessary that you have php on the
>> server.

>
> True.
>
>> Then you must name the files as "php" not html.

>
> Not true. Server setup dependent. Also the files could be named with
> extension '.php' with the URL having the "extension" '.html'. There
> are several ways to accomplish that.
>


The OP mentioned something about being hosted at Yahoo. They don't allow
an htaccess file, so in the OP's case, it would have to be so named. I
ran into this recently when I switched a client from HTML to PHP and
tried to use htaccess to redirect to the new files. Yahoo doesn't allow
it for "security" reasons, although they are running PHP 4.3.11 with
Registered Globals on.

My suggestion to the OP is to run away from Yahoo as fast as possible.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
 
Reply With Quote
 
dorayme
Guest
Posts: n/a
 
      02-13-2011
In article <(E-Mail Removed)>,
richard <(E-Mail Removed)> wrote:

> BTW, to use the php stuff, it is necessary that you have php on the server.
> Then you must name the files as "php" not html.


Not quite the last bit. You can have .html files parsed for php.

--
dorayme
 
Reply With Quote
 
Denis McMahon
Guest
Posts: n/a
 
      02-13-2011
On 12/02/11 23:44, Crappola 308 wrote:

> Is there a solution for this or am I searching in vain?


There is a solution, yes. Pay for a web hosting service that allows ssi.

I'm pretty sure that the basic problem you're having with ssi at the
moment is that your hosting service doesn't support it.

Rgds

Denis McMahon
 
Reply With Quote
 
Denis McMahon
Guest
Posts: n/a
 
      02-13-2011
On 13/02/11 01:16, Evan Platt wrote:
> On Sat, 12 Feb 2011 17:52:30 -0700, richard <(E-Mail Removed)>
> wrote:
>
>> BTW, to use the php stuff, it is necessary that you have php on the server.

>
> So far so good...
>
>> Then you must name the files as "php" not html.

>
> No, not correct. I could name them .blah if I really wanted to.
>
> Of course, what should I expect from you? You think you can't use
> .htaccess on Windows, so...


Actually the OP needs to name the files as whatever is appropriate to
have the web server parse them the way he wants.

If the server is only set up to parse *.php as php, then he has to name
them php.

If the server is set up so that other file names get parsed as php, he
could use one of those instead.

Inserting a php include into an html file eg:

<?php include("filename.ext") ?>

will only work if php processing is being applied to html files, and
that's a server configuration issue.

If it doesn't work because the server isn't configured for it, then as
he can't use ".htaccess" files to affect the server configuration, he
either needs to get the server global config changed, get his customer
specific config changed, or rename the files as php so they get parsed
as php.

Rgds

Denis McMahon
 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      02-13-2011
Adrienne Boswell wrote:
> Gazing into my crystal ball I observed "Jonathan N. Little"
> <(E-Mail Removed)> writing in
> news:ij7ao5$drt$(E-Mail Removed)-september.org:
>
>> richard wrote:
>>
>>> BTW, to use the php stuff, it is necessary that you have php on the
>>> server.

>>
>> True.
>>
>>> Then you must name the files as "php" not html.

>>
>> Not true. Server setup dependent. Also the files could be named with
>> extension '.php' with the URL having the "extension" '.html'. There
>> are several ways to accomplish that.
>>

>
> The OP mentioned something about being hosted at Yahoo. They don't allow
> an htaccess file, so in the OP's case, it would have to be so named.


As I said "Server setup dependent"

> I
> ran into this recently when I switched a client from HTML to PHP and
> tried to use htaccess to redirect to the new files. Yahoo doesn't allow
> it for "security" reasons, although they are running PHP 4.3.11 with
> Registered Globals on.


Riiiiiight. I bet it is another reason

>
> My suggestion to the OP is to run away from Yahoo as fast as possible.
>


I seconded that.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
firefox html, my downloaded html and firebug html different? Adam Akhtar Ruby 9 08-16-2008 07:55 PM
How to call a simple perl script from HTML without need of HTTPS but simple HTTP ? Wladimir Borsov Perl Misc 4 05-11-2006 09:29 AM
simple one..... from HTML to SQL to HTML... i lose my new lines Justin Rich ASP .Net 2 06-15-2005 12:43 PM
Re: Simple Simple question!!! Kevin Spencer ASP .Net 0 06-25-2004 05:25 PM
Re: Simple Simple question!!! ashelley@inlandkwpp.com ASP .Net 0 06-25-2004 04:18 PM



Advertisments