Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript onclick; the magic words?

    I need this to run on click and not on load:

    Code:
    <script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    
    	var Delay = 10;//Seconds after them clicking the link, the gateway vanishes. 
    	function setupgateway()
    	{
    	        
    	       
    		var Left = $(window).width() /2;
                    Left = Left - $('#gatewaydiv').width()/2;
    		
    		var Top = $(window).height() /2;
    		Top = Top - $('#gatewaydiv').height()/2;
    		
    		$('#gatewaydiv').css('top', Top+'px').css('left', Left+'px').css('display', 'inline');
    		$('#gatewayDimmer').width($('html').width());
    		$('#gatewayDimmer').height($('html').height());
    		$('#gatewayDimmer').css({display:'block', position:'fixed'});
    	}
    	
    	function removegateway()
    	{
    		$('#gatewaydiv').css('display', 'none');
    		$('#gatewayDimmer').css('display','none');
    	}
    	
    	$(document).ready(function()
    	{
    		$('.offerlink').click(function()
    		{
    			setTimeout('removegateway()', Delay*1000);
    		});
    		
    		setupgateway();
    	});
    </script>
    what do i need to add?

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Change this
    Code:
    	$(document).ready(function()
    	{
    		$('.offerlink').click(function()
    		{
    			setTimeout('removegateway()', Delay*1000);
    		});
    		
    		setupgateway();
    	});
    to this
    Code:
    	$(document).ready(function()
    	{
    		$('.offerlink').click(function()
    		{
    			setupgateway();
                            setTimeout('removegateway()', Delay*1000);
    		});
    		
    		
    	});
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks, i guess. i cant bring it up now. i want to bring it up onclick by clicking a specific image on my page. How do I do that?

    **edit** nvm, I figured it out. thanks
    Last edited by diseases; 12-20-2011 at 06:57 AM.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Right now what happens? Does it just reload the page? Try this
    Code:
    	$(document).ready(function()
    	{
    		$('.offerlink').click(function()
    		{
    			setupgateway();
                            setTimeout('removegateway()', Delay*1000);
                            return false;
    		});
    		
    		
    	});
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,700
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    What has this to do with HTML or CSS?
    Moved to appropriate forum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •