我的html代码
<form>
<input type="radio" name="a" value="enter burger"> Enter burger.<br>
<input type="radio" name="a" value="They decide to go left for help."> They decide to go left for help.<br>
<input type="radio" name="a" value="Walks up street."> Walks up street.<br>
<div id='proceed'>
<input style="color:darkred" type="submit" value="Proceed">
</div>
</form>
</div>
</div>
我的JavaScript代码
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type='text/javascript'>
$(function(){
$('form').on('submit',function(){
event.preventDefault();
var value=$("input[name=a]:checked").val();
switch(value){
case "enter burger": location.href='project1.html'; break;
case "Walks up street.": location.href='project2.html'; break;
case "They decide to go left for help.": location.href='project2.html'; break;
}
});
});
</script>
当我使用chrome时,它可以工作,但是当我使用Firefox时,它会显示:
file:///home/mario/Desktop/index/project.html?a = enter + burger