最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

jquery - JavaScript redirect with variables - Stack Overflow

matteradmin9PV0评论

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"
Post a comment

comment list (0)

  1. No comments so far