Javascript 弹出框未显示
这是我的按钮,我有它在我的jsp页面Javascript 弹出框未显示,javascript,jquery,Javascript,Jquery,这是我的按钮,我有它在我的jsp页面 <button type="button" class="btn btn-primary" id="offerPhoneButton" onclick="offerPhone()">Offer Phone</button> <script type="text/javascript"> function offerPhone() { var phoneDialog = $("#myPho
<button type="button" class="btn btn-primary" id="offerPhoneButton" onclick="offerPhone()">Offer Phone</button>
<script type="text/javascript">
function offerPhone() {
var phoneDialog = $("#myPhoneList").dialog({
title: 'My Phone',
autoOpen : false,
closeText : 'hide',
show : "fade",
hide : "fade",
modal : true,
width : "400px",
position: { my: "left top", at: "left top", of: window },
open : function() {
alert('hi');
// load doctor_phones.jsp into the phones dialog.
/* $(this).load('pages/doctor/write_prescription.jsp?patient_id=' + patientId + '&patient_name=' + patientName);
this doesn't work, seems to return before the content is actually loaded. */
var content = ajaxGetJQuery("pages/doctor/doctor_phones.jsp");
$("#myPhoneList").dialog("option", "title", "My Phones"); // this is necessary, b/c the title attribute doesn't work.
$(this).html(content);
}
});
$("#myPhoneList").dialog("open");
}
</script>
提供电话
这是我的剧本
<script type="text/javascript">
function offerPhone() {
var phoneDialog = $("#myPhoneList").dialog({
title: 'My Phone',
autoOpen : false,
closeText : 'hide',
show : "fade",
hide : "fade",
modal : true,
width : "400px",
position: { my: "left top", at: "left top", of: window },
open : function() {
alert('hi');
// load doctor_phones.jsp into the phones dialog.
/* $(this).load('pages/doctor/write_prescription.jsp?patient_id=' + patientId + '&patient_name=' + patientName);
this doesn't work, seems to return before the content is actually loaded. */
var content = ajaxGetJQuery("pages/doctor/doctor_phones.jsp");
$("#myPhoneList").dialog("option", "title", "My Phones"); // this is necessary, b/c the title attribute doesn't work.
$(this).html(content);
}
});
$("#myPhoneList").dialog("open");
}
</script>
电话()的功能{
var phoneDialog=$(“#myPhoneList”).dialog({
标题:“我的手机”,
自动打开:错误,
closeText:“隐藏”,
显示:“褪色”,
隐藏:“褪色”,
莫代尔:是的,
宽度:“400px”,
位置:{my:“left top”,位于:window的“left top”},
打开:函数(){
警报(“hi”);
//将doctor_phones.jsp加载到电话对话框中。
/*$(this.load('pages/doctor/write_prescription.jsp?patient_id='+patientId+'&patient_name='+patientName);
这不起作用,似乎在实际加载内容之前返回*/
var content=ajaxGetJQuery(“pages/doctor/doctor_phones.jsp”);
$(“#myPhoneList”)。对话框(“选项”、“标题”、“我的手机”);//这是必需的,b/c title属性不起作用。
$(this.html(content);
}
});
$(“#myPhoneList”)。对话框(“打开”);
}
但是,当我单击“提供电话”按钮时,弹出框不会显示。如果您发现我的脚本有任何问题,请告诉我您的代码没有问题。如果你使用
<script type="text/javascript">
function offerPhone() {
var phoneDialog = $("#myPhoneList").dialog({
title: 'My Phone',
autoOpen : false,
closeText : 'hide',
show : "fade",
hide : "fade",
modal : true,
width : "400px",
position: { my: "left top", at: "left top", of: window },
open : function() {
alert('hi');
// load doctor_phones.jsp into the phones dialog.
/* $(this).load('pages/doctor/write_prescription.jsp?patient_id=' + patientId + '&patient_name=' + patientName);
this doesn't work, seems to return before the content is actually loaded. */
var content = ajaxGetJQuery("pages/doctor/doctor_phones.jsp");
$("#myPhoneList").dialog("option", "title", "My Phones"); // this is necessary, b/c the title attribute doesn't work.
$(this).html(content);
}
});
$("#myPhoneList").dialog("open");
}
</script>
onclick="offerPhone()
您的代码必须位于这样的主体标记之间
<script type="text/javascript">
function offerPhone() {
var phoneDialog = $("#myPhoneList").dialog({
title: 'My Phone',
autoOpen : false,
closeText : 'hide',
show : "fade",
hide : "fade",
modal : true,
width : "400px",
position: { my: "left top", at: "left top", of: window },
open : function() {
alert('hi');
// load doctor_phones.jsp into the phones dialog.
/* $(this).load('pages/doctor/write_prescription.jsp?patient_id=' + patientId + '&patient_name=' + patientName);
this doesn't work, seems to return before the content is actually loaded. */
var content = ajaxGetJQuery("pages/doctor/doctor_phones.jsp");
$("#myPhoneList").dialog("option", "title", "My Phones"); // this is necessary, b/c the title attribute doesn't work.
$(this).html(content);
}
});
$("#myPhoneList").dialog("open");
}
</script>
您的代码工作正常,如中所示
<script type="text/javascript">
function offerPhone() {
var phoneDialog = $("#myPhoneList").dialog({
title: 'My Phone',
autoOpen : false,
closeText : 'hide',
show : "fade",
hide : "fade",
modal : true,
width : "400px",
position: { my: "left top", at: "left top", of: window },
open : function() {
alert('hi');
// load doctor_phones.jsp into the phones dialog.
/* $(this).load('pages/doctor/write_prescription.jsp?patient_id=' + patientId + '&patient_name=' + patientName);
this doesn't work, seems to return before the content is actually loaded. */
var content = ajaxGetJQuery("pages/doctor/doctor_phones.jsp");
$("#myPhoneList").dialog("option", "title", "My Phones"); // this is necessary, b/c the title attribute doesn't work.
$(this).html(content);
}
});
$("#myPhoneList").dialog("open");
}
</script>
<script type="text/javascript">
function offerPhone() {
var phoneDialog = $("#myPhoneList").dialog({
title: 'My Phone',
autoOpen : false,
closeText : 'hide',
show : "fade",
hide : "fade",
modal : true,
width : "400px",
position: { my: "left top", at: "left top", of: window },
open : function() {
alert('hi');
// load doctor_phones.jsp into the phones dialog.
/* $(this).load('pages/doctor/write_prescription.jsp?patient_id=' + patientId + '&patient_name=' + patientName);
this doesn't work, seems to return before the content is actually loaded. */
var content = ajaxGetJQuery("pages/doctor/doctor_phones.jsp");
$("#myPhoneList").dialog("option", "title", "My Phones"); // this is necessary, b/c the title attribute doesn't work.
$(this).html(content);
}
});
$("#myPhoneList").dialog("open");
}
</script>
JS
<script type="text/javascript">
function offerPhone() {
var phoneDialog = $("#myPhoneList").dialog({
title: 'My Phone',
autoOpen : false,
closeText : 'hide',
show : "fade",
hide : "fade",
modal : true,
width : "400px",
position: { my: "left top", at: "left top", of: window },
open : function() {
alert('hi');
// load doctor_phones.jsp into the phones dialog.
/* $(this).load('pages/doctor/write_prescription.jsp?patient_id=' + patientId + '&patient_name=' + patientName);
this doesn't work, seems to return before the content is actually loaded. */
var content = ajaxGetJQuery("pages/doctor/doctor_phones.jsp");
$("#myPhoneList").dialog("option", "title", "My Phones"); // this is necessary, b/c the title attribute doesn't work.
$(this).html(content);
}
});
$("#myPhoneList").dialog("open");
}
</script>
function offerPhone() {
var phoneDialog = $("#myPhoneList").dialog({
title: 'My Phone',
autoOpen : false,
closeText : 'hide',
show : "fade",
hide : "fade",
modal : true,
width : "400px",
position: { my: "left top", at: "left top", of: window },
open : function() {
alert('hi');
var content = ajaxGetJQuery("pages/doctor/doctor_phones.jsp");
$("#myPhoneList").dialog("option", "title", "My Phones"); // this is necessary, b/c the title attribute doesn't work.
$(this).html(content);
}
});
$("#myPhoneList").dialog("open");
}
HTML
<script type="text/javascript">
function offerPhone() {
var phoneDialog = $("#myPhoneList").dialog({
title: 'My Phone',
autoOpen : false,
closeText : 'hide',
show : "fade",
hide : "fade",
modal : true,
width : "400px",
position: { my: "left top", at: "left top", of: window },
open : function() {
alert('hi');
// load doctor_phones.jsp into the phones dialog.
/* $(this).load('pages/doctor/write_prescription.jsp?patient_id=' + patientId + '&patient_name=' + patientName);
this doesn't work, seems to return before the content is actually loaded. */
var content = ajaxGetJQuery("pages/doctor/doctor_phones.jsp");
$("#myPhoneList").dialog("option", "title", "My Phones"); // this is necessary, b/c the title attribute doesn't work.
$(this).html(content);
}
});
$("#myPhoneList").dialog("open");
}
</script>
<button type="button" class="btn btn-primary" id="offerPhoneButton" onclick="offerPhone()">Offer Phone</button>
<div id="myPhoneList" title="Basic dialog">
<p>Heading</p>
</div>
提供电话
标题
<script type="text/javascript">
function offerPhone() {
var phoneDialog = $("#myPhoneList").dialog({
title: 'My Phone',
autoOpen : false,
closeText : 'hide',
show : "fade",
hide : "fade",
modal : true,
width : "400px",
position: { my: "left top", at: "left top", of: window },
open : function() {
alert('hi');
// load doctor_phones.jsp into the phones dialog.
/* $(this).load('pages/doctor/write_prescription.jsp?patient_id=' + patientId + '&patient_name=' + patientName);
this doesn't work, seems to return before the content is actually loaded. */
var content = ajaxGetJQuery("pages/doctor/doctor_phones.jsp");
$("#myPhoneList").dialog("option", "title", "My Phones"); // this is necessary, b/c the title attribute doesn't work.
$(this).html(content);
}
});
$("#myPhoneList").dialog("open");
}
</script>
检查控制台是否有错误并输入双引号。