var num = getQueryVariable("param1");
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
alert('Query Variable ' + variable + ' not found');
}
function mynewFunction {
var numnew = num + 1;
window.location = "?image=" + numnew;
}
function myFunction() {
var numnew = num - 1;
window.location = "?image=" + numnew;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<button onclick="mynewFunction()" id="forward"><i class="fa fa-backward"></i>
</button>
<button onclick="mysecondnewFunction()"></button>
<button onclick="myFunction()"><i class="fa fa-forward"></i>
</button>
[当我按下前进按钮时,当URL为/gallerySingle.htm?image=1
时,我希望上面的代码将参数“ image”更改为2,但是它没有任何改变。
我注意到的第一件事是mynewFunction
定义不正确,您缺少了()
function mynewFunction() {
var numnew = num + 1;
window.location = "?image=" + numnew;
}