SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to replace all text before it first displays

    Hi - We have web pages that are generated by another process. And we wish to change UPPER CASE text into Mixed Case. In effect, using JavaScript, BEFORE the page displays, I need to read all HTML that is in the BODY area - and then replace the text (after manipulating it to change various text to Mixed Case text). Do I use the OnLoad event - and what (approximately) would go into my routine? Note that the Browser will always be IE. Thanks!
    Rex

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    The onload event will be useful and easy to test with, but you may want to look into an onDOMLoad function before going to production.

    As far as the script goes, you'll want to walk through all of the text elements on the page and run them through a converter.

    Caveat: Have you considered about what will happen to abbreviations?

  3. #3
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for all your comments. Yes, we have thought about abbreviations and so we will have some kind of exception table. Regarding the onload method, I am having trouble with it. Any idea why the following always shows "aaa" in the webpage instead of "bbb"?
    <html>
    <head>
    </head>
    <body>
    <script type="text/javascript" language="javascript">
    function myTest() { document.body.outerText = "bbb"; }
    window.attachEvent('onload', myTest);
    </script>
    aaa
    </body>
    </html>

  4. #4
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind. innerText and innerHTML are what I needed. Thanks

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    innerHTML is what you need. There is no such thing as innerText or outer anything.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    There is no such thing as innerText or outer anything.
    That depends on who you're asking.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •