CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Global Javascript Function

Print topic Send  topic

Author Message
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. :)

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.