datadoit
|
| Posted: 12/10/2007, 2:56 PM |
|
CCS 3.2
The same way global functions can be put into the Common file to run on
every page, can the same be done for a javascript function?
I would like a javascript function to run on every single page that gets
called, without programming that function on every page.
|
|
|
 |
DonB
|
| Posted: 12/11/2007, 11:36 AM |
|
Not that I'm going to recommend it, but you COULD add a line to Template.php
in the function LoadTemplate (at or around line 73):
// preparing file content for parsing
$file_content =
preg_replace("/<!\-\-\s*begin\s*([\w\s]*\w+)\s*\-\->/is", $delimiter .
$begin_block . $delimiter . "\\1" . $delimiter, $file_content);
$file_content =
preg_replace("/<!\-\-\s*end\s*([\w\s]*\w+)\s*\-\->/is", $delimiter .
$end_block . $delimiter . "\\1" . $delimiter, $file_content);
$file_content = preg_replace("/\\{res:\s*(\w+)\\}/ise",
"\$CCSLocales->GetText('\\1')", $file_content);
$file_content = preg_replace("/\\{(\w+(:\w+)?)\\}/is", $delimiter .
$tag_sign . $delimiter . "\\1" . $delimiter, $file_content);
# Add the following:
$file_content = preg_replace("/<\/head>/i","<script src='/MyFunctions.js'
type='text/javascript'></script>\n</head>",$file_content);
Then you can create MyFunctions.js and put whatever you want in there.
EVERY page loads the file (and from the root folder of the website), which
may not be such a great thing.
--
DonB
http://ccswiki.gotodon.net
"datadoit" <datadoit@forum.codecharge> wrote in message
news:fjkg6j$so2$1@news.codecharge.com...
> CCS 3.2
>
> The same way global functions can be put into the Common file to run on
> every page, can the same be done for a javascript function?
>
> I would like a javascript function to run on every single page that gets
> called, without programming that function on every page.
|
|
|
 |
datadoit
|
| Posted: 12/11/2007, 3:53 PM |
|
DonB wrote:
> # Add the following:
> $file_content = preg_replace("/<\/head>/i","<script src='/MyFunctions.js'
> type='text/javascript'></script>\n</head>",$file_content);
>
> Then you can create MyFunctions.js and put whatever you want in there.
> EVERY page loads the file (and from the root folder of the website), which
> may not be such a great thing.
>
Interesting. I'll rethink this idea. Actually, the javascript I want
to use on every page is to check for javascript. :)
|
|
|
 |
|