我们的一位Web开发人员使用以下html作为占位符来设置下拉列表的样式.
<a href="" class="arrow"></a>
Run Code Online (Sandbox Code Playgroud)
这被认为是锚标签有效吗?
由于没有href值,它在我们的一些链接检查器报告中显示为已损坏.
是否可以将正常链接指向当前位置?
我目前找到了2个解决方案,但其中一个包含JavaScript,另一个你必须知道页面的绝对路径:
<a href="#" onclick="window.location.reload(true);">1</a>
<a href="/foobar/">2</a>
<a href="#">3 (of course not working)</a>
Run Code Online (Sandbox Code Playgroud)
有没有办法这样做,不使用JavaScript或知道绝对路径?
我试图在一些进程后用外部javascript文件中的这个语句刷新页面.
window.location.href = window.location.href
Run Code Online (Sandbox Code Playgroud)
它完美地重新加载页面,但我想在重新加载后滚动到特定位置.所以,我把它放在页面上.
<a name="uploadImgSection"></a>
Run Code Online (Sandbox Code Playgroud)
并将javascript更改为
window.location.href = window.location.href + "#mypara";
Run Code Online (Sandbox Code Playgroud)
此代码也不会重新加载/刷新页面
window.location.hash = "#uploadImgSection";
window.location.href = window.location.href;
Run Code Online (Sandbox Code Playgroud)
当我这样做时,它根本不会重新加载页面.有什么办法可以用滚动条位置重新加载页面吗?
可能重复:
window.location.href = window.location.href和window.location.reload()之间的区别
这两行代码有什么区别,如果有,请赐教.
1.
window.location.reload();
Run Code Online (Sandbox Code Playgroud)
2.
window.location = document.URL;
Run Code Online (Sandbox Code Playgroud) window.location.reload()w3schools表示,所有浏览器均支持此功能
但是如何window.location.reload(true)在没有缓存的情况下重新加载页面呢?它的支持程度如何?
我需要在ajax调用成功时重新加载页面.
我看到了一些代码(不是我的代码),有两种方法:
success : function(obj) {
//code
location.href = location.href;
}
Run Code Online (Sandbox Code Playgroud)
要么
success : function(obj) {
//code
window.location.reload(true);
}
Run Code Online (Sandbox Code Playgroud)
这种行为有什么不同吗?我知道位置和window.location的区别,但在工作方面?
几个月前,我发布了关于如何通过JavaScript刷新页面的答案.
我也提供了一个JSFIDDLE DEMO:
var solutions = [
function () { location.reload(); },
function () { history.go(0); },
function () { location.href = location.href; },
function () { location.href = location.pathname; },
function () { location.replace(location.pathname); },
function () { location.reload(false); },
];
$("[data-func]").on("click", function () {
solutions[parseInt($(this).attr("data-func"))]();
});
Run Code Online (Sandbox Code Playgroud)
有人注意到它location.reload()比其他方法慢.现在我可以看到同样的事情.
它为什么慢?为什么其他人更快?
进度栏为100%后,我想在5秒后重新加载页面
我拥有的代码是:
<!DOCTYPE HTML>
<!--
/*
* jQuery File Upload Plugin AngularJS Demo
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2013, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* https://opensource.org/licenses/MIT
*/
-->
<html lang="en">
<head>
<!-- Force latest IE rendering engine or ChromeFrame if installed -->
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->
<meta charset="utf-8">
<title>jQuery File Upload Demo - AngularJS version</title>
<meta name="description" content="File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, …Run Code Online (Sandbox Code Playgroud) 首先要提到的是我的代码在IE8和谷歌浏览器中运行.只有在Firefox下,我才遇到问题,在Ubuntu和Win XP下测试它同样的问题.
我正在尝试在刷新页面时显示ajaxloader gif图像.在一开始我使用jquery .ready()函数来隐藏将显示图像的div#refresh.当我们点击刷新链接时,我会显示div#refresh.我的问题是ajaxloader.gif没有变得像它应该成为一个修复图像.但提到它在chrome和IE下工作.
知道为什么吗?
HTML:
<div id="refreshing">Refreshing</div>
<a href="javascript: refreshPage();">Refresh</a>
Run Code Online (Sandbox Code Playgroud)
CSS:
#refreshing {
font: 14px Verdana,Arial;
color: #00264b;
background: url("/med/base/img/ajax-loader-blue.gif") center no-repeat;
}
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
$(document).ready(
function() {
// hide the ajax loader
$("#refreshing").hide();
}
);
function refreshPage() {
$("input").attr("disabled", "disabled");
$("select").attr("disabled", "disabled");
$("img").attr("onclick", "");
$("a").attr("href", "#");
window.location.href = window.location.href;
$("#refreshing").toggle();
}
Run Code Online (Sandbox Code Playgroud)
还有一件事是firefox配置image.animation_mode设置为normal.此外,如果我看到萤火虫,图像是动画的.
谢谢大家.
我想在用户关闭由" bootstrap-multiselect "UI 控制的下拉菜单时重新加载页面.
这是我到目前为止所尝试的
$('#ts_client_id').multiselect({
enableFiltering: true,
enableCaseInsensitiveFiltering: true,
selectedClass: null,
nonSelectedText: 'All Clients',
includeSelectAllOption: true,
buttonWidth: '100%',
maxHeight: 250
}).on('blur', function () {
console.log($('#ts_client_id').val());
window.location.reload();
});
Run Code Online (Sandbox Code Playgroud)
也
$('#ts_client_id').multiselect({
enableFiltering: true,
enableCaseInsensitiveFiltering: true,
selectedClass: null,
nonSelectedText: 'All Clients',
includeSelectAllOption: true,
buttonWidth: '100%',
maxHeight: 250
}).on('hide.bs.dropdown', function () {
console.log($('#ts_client_id').val());
window.location.reload();
});
Run Code Online (Sandbox Code Playgroud)
我也尝试了这个,它没有用
$('#ts_client_id').multiselect({
onDropdownHidden: function(event){
console.log('hi');
window.location.reload();
},
enableFiltering: true,
enableCaseInsensitiveFiltering: true,
selectedClass: null,
nonSelectedText: 'All Clients',
includeSelectAllOption: true,
buttonWidth: '100%',
maxHeight: 250
});
Run Code Online (Sandbox Code Playgroud)
这是我的HTML代码
<select name="ts_client_id[]" id="ts_client_id" multiple="multiple" …Run Code Online (Sandbox Code Playgroud) 我有一个页面list.jsp列出了表格中的所有记录,一个按钮位于顶部以添加新记录.
我想打开add.jsp一个弹出窗口.这有效但当我关闭弹出窗口时如何更新, list.jsp以便它显示新添加的记录
这是我的代码,我试过...
的List.jsp
<html>
<head>
<script>
function popupwindow(url, title, w, h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
popupWindow = window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
return popupWindow
}
</script>
</head>
<body>
<input type="button" value="Add new" id="add-btn" onclick="popupwindow('Addnew.jsp','Add new',600,400)"/>
<table>
// Here i am showing all records from database...
</table>
</body>
Run Code Online (Sandbox Code Playgroud)add.jsp
<html>
<head>
<script type="text/javascript">
$(document).ready(function(){
$("#savebtn").click(function(e) {
$.ajax({
type: "POST",
url: …Run Code Online (Sandbox Code Playgroud)用户通过fancybox(javascript)弹出窗口登录后,我希望重新加载父页面,以便他们可以访问登录的功能.
目前我这样做:
<a href="javascript:window.top.location.reload(true)" class="continue">Continue</a>
Run Code Online (Sandbox Code Playgroud)
这很好用,但唯一的问题是它完全重新加载整个页面:重新下载所有的css和javascipt等.
我想要做的就是正常重新加载页面,而不是完全刷新.我怎样才能做到这一点?
(我不知道确切的URL,因为登录可以通过fancybox从任何页面完成,所以我无法对URL进行硬编码.)