Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- inserting a variable into a function


sssweb - 5:30 pm on Dec 3, 2012 (gmt 0)


I'm having a similar(?) problem elsewhere - I want to slice a string using a variable as one of the slice() parameters, but javascript doesn't read the variable. Here's my code:

var x = '/unwanted_directory_in_URL/';
var y = x.length;
URL = URL.slice(y);

My javascript knowledge is limited. The question in both cases is how to insert a variable where js is expecting a hard-coded value.


Thread source:: http://www.webmasterworld.com/javascript/4524548.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com