Run function on page load once only

In that page http://labs.voronianski.com/jquery.avgrund.js/ the popup window is shown when clicking the link. I have trying to alter the script so the modal popup comes up when the page is displayed and just once but anything I tried didn’t work.

How then to trigger this function once on page load and once only ?

$(document).ready(function(){
     functionName();
});

… is one way of doing it.

HTH,

:slight_smile:

The script shown below gives me: Uncaught ReferenceError: avgrund is not defined

<script src="../jquery.avgrund.js"></script>
<script>
$(document).ready(function() 
{avgrund({
		height: 200,
		holderClass: 'custom',
		showClose: true,
		showCloseText: 'close',
		onBlurContainer: '.container',
		template: '<p>So implement your design and place content here! If you want to close modal, please hit "Esc", click somewhere on the screen or use special button.</p>' +
		'<div>' +
		'<a href="http://github.com/voronianski/jquery.avgrund.js" target="_blank" class="github">Avgrund on Github</a>' +
		'<a href="http://twitter.com/voronianski" target="_blank" class="twitter">Twitter</a>' +
		'<a href="http://dribbble.com/voronianski" target="_blank" class="dribble">Dribbble</a>' +
		'</div>'
	});
});
</script>

I am not at all familiar with avgrund. The first thing that I would check is to make sure that the relative path to the src in your first <script> tag is correct.

Also, check to make sure that you have a closing } for your avgrund. Or remove the { before your avgrund.

V/r,

:slight_smile:

The documentation says this.

If you want to show avgrund on page load set this option value to false, example:

$(document).avgrund({
    openOnEvent: false
});

Which I suppose should be in document ready.

$(function() {
	$(document).avgrund({
         openOnEvent: false
	});
});

That will open automatically on page load.

I just copied the files and it worked straight away for me (having never seen it before).

1 Like

Which makes things worse is that I reviewed the options several times. :unamused:
Thanks Paul !

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.