Question

I want to open Reveal Modal Popup when page loads, without clicking anything

Here is what have:

<!DOCTYPE html>
<head>
    <title>Modal PopUp</title>
    <link type="text/css" rel="stylesheet" href="css/style.css">
    <link type="text/css" rel="stylesheet" href="css/reveal.css">   

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script>
    <script type="text/javascript" src="js/jquery.reveal.js"></script>

<script language="JavaScript">
$(function() {
    $( "#myModal" ).dialog();
});
</script>

</head>
<body>

    <!-- #reveal modal popup -->

        <div id="myModal" class="reveal-modal">
            <h1>Reveal Modal Goodness</h1>
            <p>This is a default modal in all its glory, but any of the styles here can easily be changed in the CSS.</p>
            <a class="close-reveal-modal">&#215;</a>
        </div>

    <!-- #reveal modal popup -->           
</body>
</html>

I don't want to use this trigger:

<a href="#" data-reveal-id="myModal">Click Me For A Modal</a>

It should open automatically.

Was it helpful?

Solution 2

you can hide the anchor tag and click it programmatically:

<a href="#" id="clickMe" data-reveal-id="myModal" style="display:none;">Click Me For A Modal</a>



$('#clickMe').click();

it will open without clicking any link or button on page but on behind we programmatically click it.

you can also do:

$("#myModal").reveal();

OTHER TIPS

Try this

$(document).ready(function() {  //or  $(window).load(function(){ 
    $('#myModal').reveal($(this).data());
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top