最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - JavaScript redirect with variables - Stack Overflow

programmeradmin12浏览0评论

So I have this JavaScript function getSearchVariable which basically acquires a variable from the URL using raw Javascript.

I need to redirect the user to a page with a URL with some static text before the variable and after the variable.

document.location.href="?="+(getSearchVariable('Track')+"&tba=N"

Any idea on why something like the code above won't work?

So I have this JavaScript function getSearchVariable which basically acquires a variable from the URL using raw Javascript.

I need to redirect the user to a page with a URL with some static text before the variable and after the variable.

document.location.href="http://example./tracer?="+(getSearchVariable('Track')+"&tba=N"

Any idea on why something like the code above won't work?

Share Improve this question asked Nov 8, 2012 at 0:39 henryaaronhenryaaron 6,21221 gold badges63 silver badges82 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

Your parenthesis are not balanced.

document.location.href=
    "http://example./tracer?="+(getSearchVariable('Track')+"&tba=N"
//                                ^
//                                |
//                                +--- Remove this guy.

Because you are missing a )

document.location.href="http://example./tracer?="+(getSearchVariable('Track')+"&tba=N"
                                                     ^1                ^2      ^2

it should be

document.location.href="http://example./tracer?="+(getSearchVariable('Track'))+"&tba=N"
发布评论

评论列表(0)

  1. 暂无评论