![](/img/trans.png)
[英]Detect notification pop-up dismissed with cancel button - Javascript - Chrome
[英]javascript ok cancel pop-up button
我已經嘗試了很多方法,但是仍然可以從表單內部訪問.js文件:請問有人可以告訴我該怎么做嗎?
這就是我要稱呼的:
<script type="text/javascript">
if (confirm("Press 'OK' to leave, or 'Cancel' if you want to stay: "))
{
window.location="http://google.com";
}
else
{
<a href="javascript:history.go(-1)">Go back</a>
}
</script>
這就是我一直在打電話的方式:
<input type="BUTTON" value="Back to Main Page" onclick= ??? >
謝謝。
var answer = confirm ("Press Ok to leave. Cancel to stay.")
if (answer)
window.location="http://google.com"
else
window.location="http://www.mysite.com/"
您正在HTML代碼中添加JavaScript代碼。 您需要將它們分開。 就像是:
document.write('<a href="javascript:history.go(-1)">Go back</a>');
會成功的
您需要將代碼變成javascript函數 ,例如
function sayHello()
{
alert('hello');
}
並在按鈕html中:
<input type="BUTTON" value="Back to Main Page" onclick="javascript: sayHello();" >
// start active and inactive confirm message box
var Regionid = '@Model.RegionID';
if (Regionid != 0) {
$(function () {
$('#inactive').change(function () {
$("#ConformationDlg").html('@Constants.ChangeStatus');
$("#ConformationDlg").dialog({
title: "",
buttons: [
{
text: "Yes",
click: function () {
$("#ConformationDlg").dialog("close");
}
},
{
text: "No",
click: function () {
$('#active').prop("checked", true);
$("#ConformationDlg").dialog("close");
}
}
]
});
});
})
}
// End active and inactive confirm message box
$(function () {
$("#btnSubmit").click(function () {
var form = $("#frm");
var Regionid = $("#hdnRegionID").val();
if (form.valid()) {
if (Regionid == 0) {
$("#ConformationDlg").html('@Constants.AddFormSubmit');
$("#ConformationDlg").dialog({
title: "",
buttons: [
{
text: "Yes",
click: function () {
window.location.href = "../RegionFoodTypes/RegionFoodTypes";
$("#ConformationDlg").dialog("close");
}
},
{
text: "No",
click: function () {
$("#ConformationDlg").dialog("close");
}
}
]
});
}
else {
$("#ConformationDlg").html('@Constants.EditFormSubmit');
$("#ConformationDlg").dialog({
title: "",
buttons: [
{
text: "Yes",
click: function () {
window.location.href = "../RegionFoodTypes/RegionFoodTypes";
$("#ConformationDlg").dialog("close");
}
},
{
text: "No",
click: function () {
$("#ConformationDlg").dialog("close");
}
}
]
});
}
}
})
})
function resetFields(form) {
$("#ConformationDlg").html('@Constants.CancelForm');
$("#ConformationDlg").dialog({
title: "",
buttons: [
{
text: "Yes",
click: function () {
window.location.href = "../RegionFoodTypes/RegionFoodTypes";
$("#ConformationDlg").dialog("close");
}
},
{
text: "No",
click: function () {
$("#ConformationDlg").dialog("close");
}
}
]
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.