作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
抱歉,我不太擅长 JavaScript,而且我才刚刚开始学习它。我有这样的场景:我想将 URL 传递到我的 iframe,那么如何用它创建一个脚本?
<script>
/* Pseudocode
if var variable1 is true then pass url to iframe with variable1 as value
else if var variable2 is true then pass url to iframe with variable2 as value
else let the default url
*/
</script>
Hope someone can know this.
Thank you!
<input type="checkbox" name="vehicle" value="(variable1)">
<input type="checkbox" name="vehicle" value="(variable2)">
<iframe id="javascriptID" src="(variable(1or2)">
</iframe>
最佳答案
您可以使用单选按钮,然后执行以下操作:
HTTPSNow
<input type="radio" name="vehicle" value="https://www.httpsnow.org/" onclick="setURL(this.value)"/>
<br/>
Example.com
<input type="radio" name="vehicle" value="https://www.example.com/" onclick="setURL(this.value)"/>
<br/>
<iframe id="javascriptID" src="" width="500px" height="500px">
</iframe>
function setURL(thelink){
javascriptID.src=thelink;
}
关于javascript - 基于复选框在 iframe 上传递 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31647401/
我是一名优秀的程序员,十分优秀!