You are missing our premiere tool bar navigation system! Register and use it for FREE!

•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
· Home
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 238 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Javascript functions in javascript.php

21.9.1. Javascript functions in javascript.php

PHP-Nuke come with its own Javascript functions included in the file javascript.php, located under the includes folder. You can add your own Javascript code there, if you follow some simple rules:

  • Use a decent text editor (see Chapter 11) to edit the file.

  • Append your code after the code already there, but before the ending ?> line.

  • "echo" each line of your Javascript script. Example: Instead of entering directly the script code:

    <script type="text/javascript">
    function openwindow(){
  • enter it with "echo"s as:

    echo "<script type=\"text/javascript\">\n";
    echo "<!--\n";
    echo "function openwindow(){\n";
    echo "\"modules/$name/copyright.php\",\"Copyright\",
    echo "}\n";
    echo "//-->\n";
    echo "</script>\n\n";
  • Enclose each line in double quotes, like a string, and escape (with a backslash \) any double quote inside that string.

  • Add a newline character (\n) to the string, before the closing double quote[1].

  • End each line, like every PHP line, with a semicolon (;).

If you use vi (see Section 11.1), the following sequence of vi commands, applied to a Javascript file, will produce the right PHP code to append in the javascript.php file:

1,$s/"/\\"/g (1)
1,$s/^/echo "/ (2)
1,$s/$/";/ (3)
1,$s/";$/\\n";/ (4)
Escape all double quotes.
Add 'echo "' at the start of every line.
Add '";' at the end of every line.
Add a newline '\n' at the end of each Javascript line.

You can then include calls to your Javascript functions in the HTML code of your module. You echo the Javascript code, just like any other HTML code.



the "" line in the example above is actually a long line that has been broken to 3 lines only for layout purposes, that's why there are no newlines (\n) at the ends of two lines (just as there is no semicolon for the same reason).

Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.157 Seconds - 155 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded ( ::