/    Sign up×
Community /Pin to ProfileBookmark

Javascript removing slashes in variable

Hi,
I am using IE8 browse. In javascript I am assigning variable filepath.
<%
String filepathXml=”C:/abc/work/work.xml”;
%>
var filepath= ‘<%=filepathXml%>’;

Here in filpath, it removes all slashes and display as
C:abcworkwork.xml

I tired by changing forward slash to backward slash in java variable. But, output is same.

Any idea?

Thanks,
Sumeet

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Mar 05.2010 — When you view the page source do you see the slashes?

Eric
Copy linkTweet thisAlerts:
@SumeetauthorMar 05.2010 — Hi,

I am using IE8 browse. In javascript I am assigning variable filepath.

<%

String filepathXml="C:/abc/work/work.xml";

%>

var filepath= '<%=filepathXml%>';

Here in filpath, it removes all slashes and display as

C:abcworkwork.xml

In view source, it is showing correct. It is showing with slashes. Here, I forgot to mention, I am assigning java file with that path to javascript variable, like :

var filepath= '<%=new File(filepathXml)%>';

But this is not file uploading by user. This is just modified xml file.

Thanks,

Sumeet
Copy linkTweet thisAlerts:
@A1ien51Mar 05.2010 — I just wanted to know this:

When you view the page source and do you see

var filepath= 'C:abcworkwork.xml';

or

var filepath= 'C:/abc/work/work.xml';

I am guessing you see the first, which means the problem is with your serverside code and not the clientside.

Eric
Copy linkTweet thisAlerts:
@SumeetauthorMar 05.2010 — It is displayed in source like:

'C:/abc/work/work.xml';

Here is important to note:

It give correct path if java string variable is assigned.

But, if it is : new File(java variable),

then I am checking in alert, it is removing all slashes.

Thanks,

Sumeet
×

Success!

Help @Sumeet spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...