Re: [PHP-GENERAL] How: Including a file in the Head Tag.
[email protected] (David Robley)
| Newsgroups | php.general |
|---|---|
| Message-ID | <[email protected]> |
On 19 May, Jess wrote:
> I hope you can assist me with a problem I am having that I have not been
> able to find a solition.
> There is a Javascript that I need to include between the <HTML> and <HEAD>
> tags. Copying via cut and paste is not a problem, but that makes switching
> the code off and on very labour intensive. The reason I need to switch it
> off is I create the web site off line on a win98 system. I have tried
> "include" but that doesn't seem to work in the HTML tag section.
>
> The general idea was to put an include tag to the file which contained the
> javascript (domain.inc) in the <HTML> tag and then either remove the java
> script from within the domain.inc file to disable the script function. To
> re-enable the script is just a matter of copy the script back into the
> domain.inc file.
>
> I am currectly reading your HTML tutorial to see if I can get any help from
> it. I have also read other html tutorials but they don't seem to get into
> this area.
>
> I would be greatfull for any assistence or guidence.
>
>
>
> <HTML>
> <script language="JavaScript">
> <!-- hide this stuff from other browsers
> // automatically forward user to a sub domain
> var hostname = location.hostname // capture the current hostname from the
> browser
> var temphn = new String(hostname) // convert the current hostname to a
> string
> var lchostn = temphn.toLowerCase() // convert the current hostname to lower
> case
> if (lchostn.indexOf("peoplemandate.com") < 0) { // reassign hostname to
> subdomain
> location.hostname = "www.peoplemandate.com"
> }
> // end the hiding comment -->
> </script>
> <HEAD>
> </HEAD>
> </HTML>
>
>
>
> Regards Jess
Just glancing at the JS it looks like you could do that with PHP anyhow,
using the header() function - there is an example for using header to
redirect in (at least my copy of) the docs.
Alternatively, you could do some sort of test at the beginning of the
script to determine whether you are on the Win machine and include the
JS file accordingly. Maybe check the IP of the host?
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA