如何在页面加载上打开对话框

我正在尝试打开一个对话框在页面上加载jquery Mobile屏幕。现在我可以打开对话框上的按钮点击。我希望对话框在页面加载时自动弹出但不能这样做。 这是HTML ..

 

You have entered:

Open Dialog

这是我的jquery ..

 function onLoad() { document.addEventListener("deviceready", onDeviceReady, false); $("#searchby_chooser_ok_button").bind ("click", searchByCriteria); if (typeof Contact === "undefined") { getElement("contacts_list").innerHTML = "

The Cordova Contacts API is inaccessible

"; } }

请帮我自动弹出页面加载对话而不是按钮点击事件。 谢谢

尝试使用$(document).ready(function(){})

 $(document).ready(function() { $("#simplestring").simpledialog({ 'mode' : 'string', 'prompt' : 'Please Enter Your Mobile No.', 'buttons' : { 'OK': { click: function () { $('#dialogoutput').text($('#dialoglink').attr('data-string')); //get the Value Entered //Create a Sqlite Database and table //Insert it there } }, 'Cancel': { click: function () { }, icon: "delete", theme: "c" } } }) }); 

您可以触发jquery代码中的单击

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

在页面加载时写下此语句。 它将从您的代码内部触发单击,并且当单击处理程序执行时,它将打开对话框:)

 function onLoad() { openDialogBox(); document.addEventListener("deviceready", onDeviceReady, false); $("#searchby_chooser_ok_button").bind ("click", searchByCriteria); if (typeof Contact === "undefined") { getElement("contacts_list").innerHTML = "

The Cordova Contacts API is inaccessible

"; } } function openDialogBox() { $("#simplestring").simpledialog({ 'mode' : 'string', 'prompt' : 'Please Enter Your Mobile No.', 'buttons' : { 'OK': { click: function () { $('#dialogoutput').text($('#dialoglink').attr('data-string')); } }, 'Cancel': { click: function () { }, icon: "delete", theme: "c" } } }) }