我想知道在用户在提示符中输入信息并单击“确定”之后我可能会重定向到某个页面,如下所示:
WITH
FUNCTION upper_string(p_string IN VARCHAR2) RETURN VARCHAR2
IS
BEGIN
RETURN UPPER(p_string);
END;
SELECT upper_string AS ret_val
FROM dual;
有很多人询问var Input = prompt("Message:");
if (//Button clicked, and Input not empty\\) {
//Sanitize input
//Redirect to https://www.MyWeb.com/?Message=INPUT
}
和alert()
等内容,但我没有发现与confirm()
答案 0 :(得分:1)
此页面可以为您提供帮助。
https://www.w3schools.com/jsref/met_win_prompt.asp
var Input = prompt("Message:");
if(Input.trim() != "" && Input == "your key")
{
location.href = "/togo";
}
else
{
alert("Fail!");
}
这就是我的理解吗?
祝你好运!答案 1 :(得分:0)
您可以尝试这样
var txt;
if (confirm("Press a button!") == true) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
document.getElementById("demo").innerHTML = txt;
有提示:
var msg = prompt("Custom Header:");
if (msg.length > 0) {
console.log('Message Added ')
} else {
console.log('Its empty')
}
答案 2 :(得分:0)
尝试这样。使用trim()
它会从字符串中删除不需要的空格
var str = prompt("Message:");
if(str == null){
console.log('pressed cancel')
}
else if (str.trim()) { //validate is not empty with empty space also
console.log('valid')
//window.location.href = "url"
} else {
console.log('empty')
}
答案 3 :(得分:0)
我想到了以下代码:
var Text = prompt ( "Message" );
if (Text != "" && Text != null) {
Text = Text.trim ( );
location.href = "https://www." + Text + ".com/"
} else {
document.write ( "Error!" );
}
它检查用户是否:
location.href
和document.write
仅用于错误测试。