Javascript.RU

PHP-функция: require_once

Зависит от

Javascript:

function require_once(filename) {	// The require_once() statement includes and evaluates the specified file during
	// the execution of the script. This is a behavior similar to the require()
	// statement, with the only difference being that if the code from a file has
	// already been included, it will not be included again.  See the documentation for
	// require() for more information on how this statement works.
	// 
	// +   original by: Michael White (http://crestidg.com)

	var cur_file = {};
	cur_file[window.location.href] = 1;

	if (!window.php_js) window.php_js = {};
	if (!window.php_js.includes) window.php_js.includes = cur_file;
	if (!window.php_js.includes[filename]) {
		if (!window.php_js.required) window.php_js.required = {};
		if (!window.php_js.required[filename]) {
			return this.require(filename);
		} else {
			return window.php_js.required[filename];
		}
	} else{
		return window.php_js.includes[filename];
	}
}

Примеры:

require_once('/js/imaginary1.js');
1


 
Поиск по сайту
Содержание

Учебник javascript

Основные элементы языка

Сундучок с инструментами

Интерфейсы

Все об AJAX

Оптимизация

Разное

Дерево всех статей

Последние темы на форуме
Forum