gpt4 book ai didi

javascript - HTML/Javascript onchange 与 onsubmit 问题

转载 作者:行者123 更新时间:2023-11-27 22:47:25 24 4
gpt4 key购买 nike

我正在尝试一个代码,它将加载一个 iframe onsubmit。我能够做到 onchange 一个文本字段(从某处获取的代码)。但是 onsubmit 不起作用:

作品

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>

</head>
<body>
<input value="Song1" onchange="foo.location='song.php?song=blind_willie.mp3'" style="display:block; margin:auto" type="text">
<iframe name="foo" style="display:block; margin:auto"></iframe>
</body>
</html>

不起作用

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">


<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>

</head>
<body>
<input value="Song1" onsubmit="foo.location='song.php?song=blind_willie.mp3'" style="display:block; margin:auto" type="Submit">
<iframe name="foo" style="display:block; margin:auto"></iframe>
</body>
</html>

最佳答案

Onsubmit 出现在表单上,​​而不是提交按钮上,尝试在“onclick”事件中使用 type="button"而不是。

关于javascript - HTML/Javascript onchange 与 onsubmit 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6367204/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com