简体   繁体   中英

Javascript-function build url

I'm working on a project, and if I can get this to work it would save me a lot of time. I want to build a url in my javascript function, with the variable as part of the url. (I'm not good at javascript so I can't explain it properly... but I can show what I've got so far). It's more complicated, but it looks something like this:

I have this function (I know it doesn't work :-) ):

function art1(range) {
top.frames['infoframe'].location.href = 'http://url_part_1' + range + 'url_part_2.html';
}

And this in the body of my page:

<a href='some_other_url' onclick='some_other_functions();art1(C15)'   >

So the result should be this url:

http://url_part_1_C15_url_part_2

EDIT: Ok, additional problem: C15 is in another function, namely here:

function changeText(){
var newHTML = "<td class='tas'><a href='_some_link_' target='changer' 
onclick='setVisibility2();art1(C15)'   (...)

C15 is a variable (which is, presumably, undefined ). You want a string literal instead: "C15" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM