admin管理员组文章数量:1434967
the html page contains 3 radio buttons- red,green, blue.If we selected any one of radio button, onw new window has to open, and that window background color should be the selected radion button color. can anyone help me how to solve this..
the html page contains 3 radio buttons- red,green, blue.If we selected any one of radio button, onw new window has to open, and that window background color should be the selected radion button color. can anyone help me how to solve this..
Share Improve this question asked Jul 4, 2012 at 11:43 harikaharika 331 gold badge2 silver badges7 bronze badges3 Answers
Reset to default 1Try this (demo on jsbin., you might need to allow popups):
HTML:
<label for="red">Red</label>
<input type="radio" id="red" name="windowcolor" data-color="red" />
<label for="green">Green</label>
<input type="radio" id="green" name="windowcolor" data-color="green" />
<label for="blue">Blue</label>
<input type="radio" id="blue" name="windowcolor" data-color="blue" />
JavaScript:
function openWindowWithColor() {
var color = this.getAttribute("data-color");
console.debug("Open new window with color: " + color);
var myNewWindow = window.open();
myNewWindow.document.body.style.background = color;
}
var radios = document.getElementsByTagName("input");
for(var i = 0; i < radios.length; i++) {
radios[i].addEventListener("change", openWindowWithColor);
}
<script>
function open(var color){
//window.open("new_page.html#"+color);
var myNewWindow = window.open("url");
myNewWindow.document.body.style.background = color;
}
</script>
<input type="radio" onclick="open('red')" />
<input type="radio" onclick="open('green')" />
<input type="radio" onclick="open('blue')" />
var newwindow = window.open('popup.aspx','Color Popup','height=400,width=200');
newwindow.document.body.style.background = "#000";
本文标签: javascriptIn HTMLopen a new window with selected background colorStack Overflow
版权声明:本文标题:javascript - In html, open a new window with selected background color - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745626884a2667026.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论