Solved

ä in JS (å, ä, ö, ü)

Posted on 1997-09-29
9
598 Views
Last Modified: 2012-05-04
I need to be able to put the umlaut-letters in a jacascript ticker. How do i do this?
Algabatz
0
Comment
Question by:algabatz
9 Comments
 
LVL 3

Expert Comment

by:gwalters
ID: 1270796
Works fine for me, both netscape and iexplore.  Could you post your code and tell what's wrong?


0
 
LVL 1

Author Comment

by:algabatz
ID: 1270797
Here it is, courtesy Kollegov:
 <html>
                                         <head>
                                         <script>
                                         messages = new Array()
                                         messages[0]="&aring;&auml;&ouml;"
                                         messages[1]="Calle har mjäll"
                                         messages[2]="Linda skriver böcker"
                                         messages[3]="Sture hoppar"

                                         var n=0
                                         var nmessages=3
                                         function scroll()
                                         {
                                         document.kaka.kaka.value=messages[n];
                                         n++;
                                         if(n>nmessages) n=0;
                                             
                                         setTimeout("scroll()",2000)
                                         }


                                         </script>


                                         </head>

                                         <body onLoad="scroll()">
                                         <FORM NAME=kaka>
                                         <input name=kaka type=text size=40>
                                         </form>

                                            </body>
                                         </html> c
0
 
LVL 1

Author Comment

by:algabatz
ID: 1270798
BTW:
i would actually prefer an applet that works in the same way, where i can change the text , colour of the text and the colour of the background with params. I have found free applets but they all scroll. This is the closest to what i want, though.
Algabatz
0
 
LVL 1

Expert Comment

by:rsf
ID: 1270799
For some good and cheap applets check out http://www.opencube.com

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Expert Comment

by:Christian_Wenz
ID: 1270800
have you tried escape/unescape?
0
 
LVL 1

Author Comment

by:algabatz
ID: 1270801
I don't get it... what do you mean?
0
 

Expert Comment

by:Levin
ID: 1270802
escape/unescape is a way to (de)code strange/illegal characters into codes (prefixed by a %). I don't know how that could help you though.

BTW
Try using real åäös instead. It'll work on most platforms.
(Who cares about mac-users anyway???)
0
 
LVL 1

Author Comment

by:algabatz
ID: 1270803
Well, you know us Mac-users secretly rule the world...  
I have the same problem on a unix-based CGI though, (CGIEMAIL), it reads from a template but ignores all åäö:s (getting strange signs instead)
0
 
LVL 6

Accepted Solution

by:
Holger101497 earned 50 total points
ID: 1270804
Well, this is indeed strange. This is the first time I have this problem; the JavaScript quotes seem to stop Netscape from interpreting the &specialchars;  
I did not find a way to stop it from doing so.
I did, however, find a way to make your ticker work. This is actually a workaround that works fine for this situation, because Netscape obviously DOES transform the &uml; in form-values.
Try this:

<html>
 <head>
  <script>
    function scroll()
    {
     with (document.kaka) {
          // this is a better way of rotating:
          // shorter and "auto-detects" the length
          // also saves one variable and eliminates bugs
          // resulting from wrong "nmessages"-value
          // works for any array, e.g. messages.length
      kaka.value=tickertxt[n++].value;
      n %= tickertxt.length; // %= is n=n MOD length
     }
     setTimeout("scroll()",2000)
    }
</script>


</head>
<body onLoad="n=0;scroll()">
<FORM NAME=kaka>
<input name=kaka type=text size=40>
     // ANYthing you want in these fields
<input type=hidden name=tickertxt value="&aring;&auml;&ouml;&copy;&reg;&frac34;">
<input type=hidden name=tickertxt value="Calle har mj&auml;ll">
<input type=hidden name=tickertxt value="Linda skriver b&ouml;cker">
<input type=hidden name=tickertxt value="Sture hoppar">
</form>
</body>
</html>

Good luck!

P.S.: If you are still looking for a different JS-solution, chekc this out, works for me (strangely enough), might offer different possibilities:
<form>
  <input type=text name=txt value="&auml;">
  <input type=button value=" add " onClick="txt.value+='H&auml;gar'"> //DOES replace it here!!!
  <input type=button value=" echo " onClick="alert(txt.value)">
  <input type=button value=" rotate " onClick="txt.value=txt.value.substring(1,999)+txt.value.charAt(0)">
</form>

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now