Javascript-форум (https://javascript.ru/forum/)
-   Events/DOM/Window (https://javascript.ru/forum/events/)
-   -   Проблема с модальное окном :( (https://javascript.ru/forum/events/7672-problema-s-modalnoe-oknom.html)

Andrey[SF] 14.02.2010 09:54

Проблема с модальное окном :(
 
Всем доброе утро!)

У меня вылезла вот такая проблема, есть у меня скриптик который открывает модальное окно только при нажатии на вот такую ссылку:

<a href='#window' name='modal'>

а мне нужно что бы окно открывалось после загрузки страницы.

код:


$(document).ready(function() {

	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		//Get the A tag
		var id = $(this).attr('href');

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();

		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});

		//transition effect
		$('#mask').css('opacity', 0).show();
		$('#mask').fadeTo("slow",0.5);

		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();

		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);

		//transition effect
		$(id).fadeIn(500);

	});

	//Закрытие окна по клику на кнопку
	$('#window .close').click(function (e) {
		e.preventDefault();
		$('#mask, #window').hide();
	});



});


ЗЫ. скрипт находится в отдельном JS файле


Часовой пояс GMT +3, время: 04:12.