473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Link defined in 'var' breaking at space chars

57
Ok, the title might not make it clear.

I have a javascript code which generates an email. The page is on our corporate intranet so I know it will fire up the email ok.

the code looks something like this:

Expand|Select|Wrap|Line Numbers
  1. var ct9000 = document.getElementById("ct9000").value;
  2. var enddate = document.getElementById("105end").value;
  3. var fileloc = "file:///S:\folder1\folder2\folder - 3 \document.doc'";
  4. var body_message = "Please run "+job+", details as below:%0D%0DCT9000 ID: "+ct9000+"%0DEnd Date: "+enddate+"%0DATTN IT Ops Officer:%0DJob Notes at%0D"+fileloc;
  5. var mailto_link = 'mailto:'+email+'?subject='+subject+'&body='+body_message; 
  6.  
  7. win = window.open(mailto_link,'emailWindow'); 
  8. if (win && win.open &&!win.closed) win.close();
So you can see the link is predenfined in the "var fileloc" line, and it contains spaces. When the email is generated the link breaks at the space character, causing the link to fail.

I have tried replacing the space characters with %20 - but the same thin happens.

You could argue that I could change the path so it doesn't contain spaces, but there are so many different paths/files that it would make it a mamoth task.

Thanks in advance...
Jan 10 '08 #1
5 1729
acoder
16,027 Expert Mod 8TB
Change the backslashes into forward slashes.
Jan 10 '08 #2
plumba
57
Change the backslashes into forward slashes.
Hi

Thakns for the suggestion but it still ends the link when it reaches the first space (or is %20 equivelant).....
Jan 11 '08 #3
acoder
16,027 Expert Mod 8TB
Why do you need to use window.open for the mailto link? A mailto link should open the default mail application.
Jan 11 '08 #4
plumba
57
You're right, it does.

But i still have the problem of it not putting in the whole link......
Jan 11 '08 #5
acoder
16,027 Expert Mod 8TB
Use encodeURIComponent, e.g.
Expand|Select|Wrap|Line Numbers
  1. var mailto_link = 'mailto:' + encodeURIComponent(email) + '?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(body_message);
Jan 11 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

26
by: JGH | last post by:
How can I check if a key is defined in an associative array? var users = new array(); users = "Joe Blow"; users = "John Doe"; users = "Jane Doe"; function isUser (userID) { if (?????)
17
by: Eric Lindsay | last post by:
For years I have had links to a stylesheet done like <link rel=stylesheet type="text/css" href="style.css"> and these pages all validate with the W3C validator. However in looking at W3C, I...
6
by: jeet_sen | last post by:
Hi, I have generated a table and have attached a pop up to display at onmouseover event of each cell. For each cell the pop up will display cell specific detailed data. I have generated the pop...
14
by: hgraham | last post by:
Hi, I'm trying to understand how to work the dom, and all I'm trying to do is insert a link right before another link in the html based on it's href value. This isn't a real world example - I'm...
1
by: Sylaris | last post by:
hi, i have a problem which recursion fits perfectly, however; after working with the base function (which has no errors and works correctly) the recursions return a "function not defined" error in...
0
by: Chrom_ | last post by:
Mysql is filling my /var partition because the log limit doesn't seem to be respected. I've tried many different settings in /etc/mysql/my.cnf but nothing works. Logrotate is not...
3
by: Steve Swift | last post by:
Given a choice between: 1. <A HREF=z><NOBR>Non breaking link</NOBR></A> 2. <NOBR><A HREF=z>Non breaking link</A></NOBR> .... a nothing else; absolutely nothing else, is there any reason to...
6
by: Nehil | last post by:
i've following union union header { struct { unsigned int size; union header *next; }s;
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.