Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The HTML:
- <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
- <script src="http://example.com/scripts/loader.js"></script>
- The PHP:
- if ($something == $somethingelse) {
- echo ("<div id=\"errorMessage\">Some error message</div>);
- }
- The loader.js
- function include (filename) {
- var js = document.createElement('script');
- js.setAttribute('type', 'text/javascript');
- js.setAttribute('src', filename);
- js.setAttribute('defer', 'defer');
- document.getElementsByTagName('HEAD')[0].appendChild(js);
- 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]) {
- window.php_js.includes[filename] = 1;
- } else {
- window.php_js.includes[filename]++;
- }
- return window.php_js.includes[filename];
- }
- include('http://example.com/scripts/PopUpMessages.js');
- $(document).ready(function() {
- $("#errorMessage").PopUpMessages({
- textColor: '#ffffff',
- backgroundColor: '#ff5555',
- borderColor: '#800000'
- });
- });
- The PopUpMessages.js
- (function($) {
- $.fn.PopUpMessages = function(options) {
- var defaults = {
- fadeInTime: '1000',
- fadeOutTime: '1000',
- textColor: '#333333',
- backgroundColor: '#ffdd55',
- borderColor: '#aa8800'
- };
- var options = $.extend(defaults, options);
- $(this).fadeIn(options.fadeInTime);
- };
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement