Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Javascript CarraigeReturn not working NS6
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 31 October 2001 :  06:22:48  Show Profile  Visit Kat's Homepage
I have the following:

function replace(string,text,by) {
// Replaces text with by in string
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) || (txtLength == 0)) return string;

var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return string;
if (i == -1) return string;

var newstr = string.substring(0,i) + by;

if (i+txtLength < strLength)
newstr += replace(string.substring(i+txtLength,strLength),text,by);

return newstr;
}


and:

<script language="JavaScript">
document.write(replace(window.opener.document.JobsInput.CompanyProfile.value,'\r','<br>'));
</script>


This replace works in NS4 and IE but not NS6. I am trying to replace all CarraigeReturns with the HTML <br> tag.

Please can anyone help me figure out why NS6 doesn't like this?

Thanks.

KatsKorner


Edited by - kat on 31 October 2001 06:31:18

Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 31 October 2001 :  06:40:37  Show Profile  Visit Kat's Homepage
I fixed it. Odd because I tried this earlier and it didn't work then. But is does now.. Weird.


document.write(replace(window.opener.document.JobsInput.CompanyProfile.value,'\n','<br>'));


KatsKorner
Go to Top of Page

Aznknight
Senior Member

USA
1373 Posts

Posted - 31 October 2001 :  14:01:18  Show Profile  Send Aznknight an AOL message  Send Aznknight an ICQ Message
yeah the code with the replace on "\n" looks right. Interesting replace() function kat.

- Alan
www.iamviet.com
Snitz Resource
Go to Top of Page

Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 01 November 2001 :  04:14:10  Show Profile  Visit Kat's Homepage
quote:

yeah the code with the replace on "\n" looks right. Interesting replace() function kat.

- Alan
www.iamviet.com
Snitz Resource



Why? I was given it by a colleague. It is also on irt.org.

KatsKorner
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.2 seconds. Powered By: Snitz Forums 2000 Version 3.4.07