gpt4 book ai didi

javascript - 使用 Javascript 更改 iframe src

转载 作者:IT王子 更新时间:2023-10-29 02:46:58 28 4
gpt4 key购买 nike

我正在尝试更改 <iframe src=... >当有人点击单选按钮时。出于某种原因,我的代码无法正常工作,我无法找出原因。这是我所拥有的:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>

<script>
function go(loc) {
document.getElementById('calendar').src = loc;
}
</script>
</head>

<body>
<iframe id="calendar" src="about:blank" width="1000" height="450" frameborder="0" scrolling="no"></iframe>

<form method="post">
<input name="calendarSelection" type="radio" onselect="go('http://calendar.zoho.com/embed/9a6054c98fd2ad4047021cff76fee38773c34a35234fa42d426b9510864356a68cabcad57cbbb1a0?title=Kevin_Calendar&type=1&l=en&tz=America/Los_Angeles&sh=[0,0]&v=1')" />Day
<input name="calendarSelection" type="radio" onselect="go('http://calendar.zoho.com/embed/9a6054c98fd2ad4047021cff76fee38773c34a35234fa42d426b9510864356a68cabcad57cbbb1a0?title=Kevin_Calendar&type=1&l=en&tz=America/Los_Angeles&sh=[0,0]&v=1')" />Week
<input name="calendarSelection" type="radio" onselect="go('http://calendar.zoho.com/embed/9a6054c98fd2ad4047021cff76fee38773c34a35234fa42d426b9510864356a68cabcad57cbbb1a0?title=Kevin_Calendar&type=1&l=en&tz=America/Los_Angeles&sh=[0,0]&v=1')" />Month
</form>

</body>

</html>

最佳答案

在这种情况下,可能是因为您在这里使用了错误的括号:

document.getElementById['calendar'].src = loc;

应该是

document.getElementById('calendar').src = loc;

关于javascript - 使用 Javascript 更改 iframe src,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3730159/

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