Register on the forum now to remove ALL ads + popups + get access to tons of hidden content for members only!
|
|
#1 |
|
Registered User
Join Date: Mar 2002
Location: VA
Posts: 1,630
|
Here's the deal: I have an alert and by using \n I can get it to do a carriage return in the alert box. Is it possible to transfer this to the text output by the HTML?
If the \n is place in a document.write() statment, it doesn't appear, but the return isn't visible, nor does it become apparent on copy and paste of the text in to tex editor. Any ideas? FYI: It must be a carriage return of sometype. HTML tags will not work, or I'd just throw in a <br> or two. |
|
|
|
|
|
|
|
#2 |
|
Registered User
|
It works fine just like this:
<pre> <script language="JavaScript"> line = "this \n is \n a \n bunch \n of \n lines"; document.writeln(line); </script> </pre>
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Never Underestimate the Power of Stupid People in Large Groups. |
|
|
|
|
|
#3 |
|
Registered User
Join Date: Mar 2002
Location: VA
Posts: 1,630
|
Here's the deal
I was working on the attached script, and I'm trying to get it to issue a line return in the body of the email to seperate the form values.
Any ideas? |
|
|
|
|
|
#4 |
|
Registered User
|
Figured it out...
FINALLY... this one had my brain going. You've got to use a handy string property called fromCharCode()
basically I added a line like this: var newLine = String.fromCharCode(0013); //inputs the ASCII character for a carraige return. So you can use newLine for the carriage return anywhere you please. The script works fine like this: Code:
<html>
<head>
</head>
<body>
<form name="mailForm">
<input type="hidden" name="sendTo" value="email@address.com">
<input type="hidden" name="subject" value="JavaScript Email Submitter">
Name: <input type=text name=name><br>
Email: <input type=text name=email><br>
Body:<br><textarea name="body" rows=10 cols=50 onblur="checkValues()"></textarea><br>
<input type=button value="Compile Email" onclick="runTest()">
<script type=text/javascript>
<!--
to = document.mailForm.sendTo.value;
subject = "?subject="+document.mailForm.subject.value;
function checkValues(){
var newLine = String.fromCharCode(0013); //inputs the ASCII character for a carraige return.
name = "name: "+document.mailForm.name.value+ " ";
email = "email: "+document.mailForm.email.value + " ";
body = "&body=" + name + newLine + email + newLine + document.mailForm.body.value;
}
function runTest(){
document.getElementById('testValues').innerHTML="<a href='mailto:"+to+subject+body+"'>Click\tMe To Send Email!</a>";
}
// -->
</script>
</form>
<div id=testValues></div>
</body>
</html>
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Never Underestimate the Power of Stupid People in Large Groups. |
|
|
|
|
|
#5 |
|
Registered User
Join Date: Mar 2002
Location: VA
Posts: 1,630
|
BooYah!
Excellent!
joeboe you rock dude! |
|
|
|
|
|
#6 |
|
Registered User
Join Date: Mar 2002
Location: VA
Posts: 1,630
|
OH No!
Um... Joe,
It's not working. I copied the script, with your modification, but it's not working. It's all still on one line. Thanks for trying. Much appreciated. |
|
|
|
|
|
#7 |
|
Registered User
|
hmmm. very strange. What is the mail client on the machine your testing it with? I was using outlook 2000. It was also IE. version 6. It could be a compatibility issue.
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Never Underestimate the Power of Stupid People in Large Groups. |
|
|
|
|
|
#8 |
|
Registered User
|
FYI
Netscrape won't support this script. I get the error "document.getElementById is not a function". I also noticed some other stuff that I believe is unique to Microshaft such as the innerHTML property that is used.
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Never Underestimate the Power of Stupid People in Large Groups. |
|
|
|
|
|
#9 |
|
Registered User
Join Date: Mar 2002
Location: VA
Posts: 1,630
|
Ah!
At home I'm using Outlook Express 6
I'll try it at work where I'm using Outlook 2K. I'll let you know how it goes. |
|
|
|
|
|
#10 |
|
Registered User
Join Date: Mar 2002
Location: VA
Posts: 1,630
|
Compatibility
It does work on Outlook 2K, but apparently not on Outlook Express.
It does work with NS 6.2, and no NS4.x doesn't support the getElementByID() method. NS4.x will support the innerHTML method, but you have to do some tricky coding to make it work, and I've never succesfully done it. I know that the innerHTML will not work onLoad. It only works after the page has been parsed by the browser. |
|
|
|
|
|
#11 |
|
Registered User
|
Is your outlook set to use html format in a message by default? That would effect the way a new line is displayed.
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Never Underestimate the Power of Stupid People in Large Groups. |
|
|
|
|
|
#12 |
|
Registered User
Join Date: Mar 2002
Location: VA
Posts: 1,630
|
Yes
Yep,
HTML is the default format. |
|
|
|
|
|
#13 |
|
Registered User
|
See now that presents a whole other problem. How would one go about detecting the settings in the default email editor?
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Never Underestimate the Power of Stupid People in Large Groups. |
|
|
|
|
|
#14 | |
|
Registered User
|
Quote:
Hope that helps! ![]() Happy coding!
__________________
del society.exe - if only you could use a command line in the real world |
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Who Else Wants To Get 300% Return On Investment !! | wilsonkck84 | Making money on the web | 0 | 08-25-2006 11:07 PM |
| Please review my website, will return the favour | bad_bob00 | Review My Website | 7 | 08-24-2006 07:28 PM |
| Best return on investment | pure | Making money on the web | 1 | 04-25-2006 01:31 PM |
| How to validate Multiple Email addresses in a form input box | webbgirl | Javascript | 2 | 06-06-2005 09:59 AM |