我有两个网页A和B.网页A包含一些单选按钮。我只想要,如果用户选择任何单选按钮,则应打开网页B.
任何人都可以帮我解决我应该尝试做什么的事情?
答案 0 :(得分:1)
假设您有jQuery:
<input type="radio" name="mything" value="1"/>
<input type="radio" name="mything" value="0"/>
$('input:radio[name="mything"]').change(
function(){
if ($(this).is(':checked') && $(this).val() == '1') {
window.location = "http://www.yoururl.com";
}
else{
window.location = "http://www.yourotherurl.com";
}
});
Javascript重定向:How to redirect to another webpage in JavaScript/jQuery?
答案 1 :(得分:1)
您需要以这种方式将onclick
属性添加到您的radiobuttons:
<input type='radio' onclick='functionCalled()' />
然后在单选按钮下添加:
<script>
function functionCalled() {
window.open(url); //if you want to open in new window
window.location = url; //if you want to redirect
}
</script>
答案 2 :(得分:1)
试试这个:
<input type="radio" onchange="window.location.replace('URL_OF_WEBSITE')">