当在<选择>-HTML
reload page when item selected in <select> - HTML
关于<select></select>
的使用,我有一个小问题
我通过请求从服务器接收数据。对于这个请求,我使用了shtml。
现在我想要的是,当用户在deselectbox中选择一个项目时,页面会从服务器获取该项目的数据。对服务器的请求可能类似于%! tcp-connections
因此,我认为我必须使用JavaScript或类似的东西刷新页面。有人能告诉我怎么做吗?
HTML:
<select id="select">
<option selected>Default</option>
<option value="refresh">Refresh</option>
</select>
JavaScript:
function onchange(e) {
if (e.currentTarget.value === 'refresh') {
window.location.reload();
}
}
document.getElementById('select').addEventListener('change', onchange);
演示:http://jsfiddle.net/w425208t/
使用window.location.href = yourUrl;
它将"重定向"到url为yourUrl
的页面
您可以使用以下任何一种:
window.location.reload(false);
// If we needed to pull the document from
// the web-server again (such as where the document contents
// change dynamically) we would pass the argument as 'true'.
//i.e. 'true' will force the page to reload from the server. 'false' will reload from cache, if available.
or
location.reload();
or
window.location.replace(window.location.pathname);
相关文章:
- 样式<身体>并且<html>来自React
- Tinymce删除<html>在文本区域中输出时标记
- 把手包裹<!DOCTYPE html>
- 未捕获的语法错误:意外的标记<在<!DOCTYPE html>
- 如何将(CSS/HTML)的包链接在一起.CSS/HTML->CSS/HTML->CSS/HTML
- 中心未定义-<!DOCTYPE html>错误
- 放置JavaScript函数的位置:<头><身体>?或者在</html>
- 代码在以下情况下不起作用:<!DOCTYPE html>顶部
- Click事件穿透到<html>要素
- 我如何引用<HTML>元素's对应的DOM对象
- Onload函数下拉时间<HTML>
- HTML>根据窗口和图像大小旋转和缩放图像
- <HTML>可以't在下拉列表中选择相同的值.验证<HTML>
- 如何将.css和.js文件链接到丢失的HTML<html>并且<头部>标签
- <HTML>上一个日期Vallition
- 可以't重写<选项>当<!DOCTYPE html>目前
- 访问<html>节点
- 谷歌分析标签在</身体>并且</html>
- 当<!DOCTYPE html>添加到JSP页面
- Html>购物车按钮