Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Javascript help!

Javascript help!
Thread Tools
Professional Poster
Join Date: Jan 2001
Location: Australia, the greatest country in the world, (Australians keep telling me).
Status: Offline
Reply With Quote
Jun 6, 2004, 09:05 AM
 
Im having a problem with my site www.babelbloodyfish.com

The javascript only works in Safari, I need it to work in IE 5/6 for PC too.

Any ideas?

Thanks,

Tom.
     
Mac Enthusiast
Join Date: Feb 2002
Location: Minnesota
Status: Offline
Reply With Quote
Jun 7, 2004, 05:31 PM
 
Not sure but try changing....

onClick="cleanText(document.forms[0].jstext)"

to

onClick="jacascript:cleanText(document.formName.js text)"

Make sure to name the form.
     
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Jun 8, 2004, 09:25 AM
 
Twister: nooo......

I took a look at the page yesterday, and there is something screwy that it crashing JavascriptCore... I have not localized it yet, but my first guess is an encoding issue....

onClick="cleanText(document.forms[0].jstext)"

to

onClick="jacascript:cleanText(document.formName.js text)"
This should be:
Code:
onClick="cleanText(document.forms[0].elemts['click me'].jstext)"
IE is very forgiving in making JavaScript errors... but sometimes odd in its interepretations. This is the canocial name for the object, and will work in all JavaScript implementations.
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Jun 8, 2004, 11:09 AM
 
Originally posted by larkost:
Twister: nooo......
I took a look at the page yesterday, and there is something screwy that it crashing JavascriptCore... I have not localized it yet, but my first guess is an encoding issue....
[In a voice not dissimilar to Alf from Home and Away...]

Look ya bunch of flamin galahs, you're barking up the wrong bloody gum tree. Stone the crows, a blue-assed fly could see the RegExp is stuffed, the script needs a kick up the khaiber and the replace is more rotten than a dead dingo's donger.

[..Ahem..]

You need to create a valid RegExp in order for .replace() to do its job properly.

So first you need to escape all RegExp characters in the script

E.g.
Code:
addWord("//."," //. "); addWord(";"," ; "); addWord("!"," ! "); addWord("//?"," //? "); addWord(","," , ");
Then in the main function:-

Code:
function cleanText(formelement) { for (i=0; i <keyArray.length; i++) { var str = keyArray[i]; var item = new RegExp(keyArray[i],'g'); formelement.value = formelement.value.replace(item, replaceArray[str]); } }
This worked for me in Safari (too busy drinking VB to test any other flamin browser)
Computer thez nohhh...
     
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Jun 8, 2004, 12:00 PM
 
I've never seen two forward slashes used to escape characters - I thought a single backslash would do (or am I missing something - I'm not on VB, just plain Carlsberg export)... And didn't the original script work in Safari?

Also, didn't Arkham_C write this script in another thread? He might be the best person to ask - especially since the last two replies in this thread are from people who are pissed (or on their way to being)

p.s. mmmmmmmm, Victoria Bitter. I always have that when I go to Bar Oz in Newcastle
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Jun 8, 2004, 01:12 PM
 
Originally posted by Simon Mundy:
[In a voice not dissimilar to Alf from Home and Away...]

Look ya bunch of flamin galahs, you're barking up the wrong bloody gum tree. Stone the crows, a blue-assed fly could see the RegExp is stuffed, the script needs a kick up the khaiber and the replace is more rotten than a dead dingo's donger.

This worked for me in Safari (too busy drinking VB to test any other flamin browser)
hahahahahahahahaha!!! awesome. Alf Stewart rules!

attention to detail too, i like it: Alf wouldn't drink that noncey Crown lager, he's a VB man!
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
Professional Poster
Join Date: Jan 2001
Location: Australia, the greatest country in the world, (Australians keep telling me).
Status: Offline
Reply With Quote
Jun 12, 2004, 04:10 AM
 
Originally posted by larkost:
Twister: nooo......

I took a look at the page yesterday, and there is something screwy that it crashing JavascriptCore... I have not localized it yet, but my first guess is an encoding issue....



This should be:
Code:
onClick="cleanText(document.forms[0].elemts['click me'].jstext)"
IE is very forgiving in making JavaScript errors... but sometimes odd in its interepretations. This is the canocial name for the object, and will work in all JavaScript implementations.
Thanks but this doesn't work, it breaks it in Safari.
Im tearing my hair out over this!
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Jun 12, 2004, 10:10 AM
 
Originally posted by moonmonkey:
Thanks but this doesn't work, it breaks it in Safari.
Im tearing my hair out over this!
You have some non-printing characters in your source code. When I view the source of the frame in Safari, I see this:



If you fix that, you may find that some of the other problems go away.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Jun 12, 2004, 10:33 AM
 
Originally posted by Arkham_c:
You have some non-printing characters in your source code. When I view the source of the frame in Safari, I see this:

If you fix that, you may find that some of the other problems go away.
grr. i hate that. i soon learnt to have invisibles on in BBE, if i'd copy/pasted some code off a web page. those blighters always seemed to sneak in. (seems to be opt+space, mostly)
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
Professional Poster
Join Date: Jan 2001
Location: Australia, the greatest country in the world, (Australians keep telling me).
Status: Offline
Reply With Quote
Jun 23, 2004, 08:16 AM
 
Originally posted by Arkham_c:
You have some non-printing characters in your source code. When I view the source of the frame in Safari, I see this:



If you fix that, you may find that some of the other problems go away.
OMG! it works!

Thanks!
( Last edited by moonmonkey; Jun 23, 2004 at 10:26 AM. )
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -4. The time now is 10:14 PM.
All contents of these forums © 1995-2015 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2015, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2