Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I am using a jquery pop on page load of index page

code
JavaScript
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.session.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript">
$(document).ready(function() {	
	
$.cookie('the_cookie', 'the_value');// error $.cookie not a function
alert($.cookie('the_cookie'));
or
$.session('the_cookie', 'the_value');// error $.session not a function
alert($.session('the_cookie'));             

var id = '#dialog';
	
		//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').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//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(2000); 	
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
		
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	
	});	
	
});

</script>


dialogue box code.
HTML
<html>
<div display: none;" id="dialog" class="window">
<table width="200" border="0" cellspacing="0">
<form style="display:inline;" action="" method="post" name="enquiry_frm" accept-charset="UTF-8" >
<tr>
<td style="padding-removed10px;">
<input name="fldname" id="fldname" type="text"  class="newsbox" onclick="setLFBlanks(this);" value="Name" style="width:130px;" /></td>
<td>
<input name="fldEmail" id="fldEmail1" type="text"  class="newsbox" onclick="setLFBlanks(this);" value="Email Address" style="width:130px;" />
</td>
</tr></table></div></html>


I am opening this on page load of index/home page every time but i want that if a user fill the box or cancel it then it should not be open again whole day or a particular period of time.

this could be possible through session or any other method.
If any of you aware of this please revert me back with the solution

Thanks
Posted
Updated 16-May-13 20:38pm
v4
Comments
Sergey Alexandrovich Kryukov 16-May-13 10:09am    
The problem is: you never know for sure who is your user, is it the same person who visited it yesterday or not, unless you use user authentication.
—SA
[no name] 17-May-13 1:37am    
Yes but i have seen this in many website there should be a way to do this.
thanks

1 solution

To track something you can use either session/cookie. In that case I would like to use cookie.
Steps at the time of page load :
1. Check for a cookie(say pop_key).
2. if exist do nothing.
3. if not exist , open the pop up.
4. create and save cookie (say pop_key) at the time of ok/cancel pop up

Here is the link to create cookie in jquery
Link1
 
Share this answer
 
v2
Comments
[no name] 16-May-13 8:41am    
thanks
but can you help me out with the code because i am not able to find code for Jquery.
or lacking some process how to do it.
Shubhashish_Mandal 16-May-13 8:43am    
check the link
[no name] 17-May-13 2:14am    
this is the main problem if i use session or cookies it shows the error
$.cookie or $.session is not a function
Shubhashish_Mandal 17-May-13 2:33am    
did you add the required plugin for "jquery-cookie" ?
[no name] 17-May-13 2:35am    
yes of-course.
that's i shocked to getting these error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900