javascript - 如何在 window.location.href 中传递 QueryString?

标签 javascript

我写了下面的javascript函数

function getval(sel)
 {
    window.location.href = "Posts?Category=<%= sel %>";
 }

但是查询字符串中不考虑sel变量的值..

取而代之的是像下面这样的值。

...../Post/Posts?Category=%3C%=%20sel%20%%3E

谁能帮帮我???

最佳答案

因为javascript不理解jsp scriptlet,

尝试,

window.location.href = "Posts?Category=" + sel;

关于javascript - 如何在 window.location.href 中传递 QueryString?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17653110/

相关文章:

javascript - jQuery 触发了事件,即使它应该仍在

javascript - Angularjs ng-disabled 不起作用

javascript - 当我运行 index.html 时 android 没有检测到我的 .css 和 .js 文件怎么办?

javascript - 如何使用 Leaflet 单独设置 GeoJSON GeometryCollection 的每个几何图形的样式

javascript - 无法从下拉列表中选择值

javascript - 如何对数组进行排序然后获取索引并使用索引移动所有对应的元素?

javascript - 如何使用 jQuery 使变量随机多次

javascript - sapui5 - 如何从 SegmentedButton 隐藏一个按钮?

javascript - 动态更改字体大小时到基线的恒定距离 - html - 文本元素

javascript - Moment js Time Ago 计算错误日期