我的网站上有一个表单来生成 url,它运行良好,但用户应该等到整个页面加载后才能正确使用它,我认为这是因为我使用 window.onload 而我应该使用 $(document ).ready 代替它,但我无法替换它我需要有人帮助我
<script type='text/javascript'>
window.onload = function() {
document.forms['filterform'].onsubmit = filterLoad;
};
function filterLoad() {
var url,
colourSel = this.elements['department'],
shapeSel = this.elements['country'];
url = ( colourSel.options[colourSel.selectedIndex].value ) + ( shapeSel.options[shapeSel.selectedIndex].value );
window.location.href = url;
return false;
}
</script>
<form id="searchform" name="filterform">
<select class="chosen" name="department" id="searchfield" >
<option value="http://www.mysite.com/">choise 1</option>
<option value="http://www.mysite.com/">choise 1</option>
</select>
<select class="chosen" name="country" id="choose">
<option value="?qatar=show&action=Filter">qatar</option>
<option value="?ksa=show&action=Filter">ksa</option>
</select>
<label for="search"><button class="submit" onclick="filterLoad()" /></button></label>
</form>