2014-04-04 68 views
0

我想開顯示模式彈出時,頁面加載,無需任何點擊自動打開reaveal模式

這裏是有:

<!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> 

我不想使用此觸發器:

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

它應該會自動打開。

+0

$( '#myModal')顯示();應該告訴你模態 – DoXicK

回答

1

可以隱藏錨標記,點擊它編程:

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



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

將不點擊頁面上的任何鏈接或按鈕打開,但我們編程單擊它背後。 。

你也可以這樣做:

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

這是一個天才的想法!謝謝! –

+0

歡迎您... :) –

3

試試這個

$(document).ready(function() { //or $(window).load(function(){ 
    $('#myModal').reveal($(this).data()); 
});