New String Method wont work?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Connelly
    New Member
    • Jan 2011
    • 103

    New String Method wont work?

    I am in the learning stage of coding for Web. Here is my Code. I placed in bold and italic function that is not working.
    <html>
    <head>
    <title>JavaScri pt Business Cards</title></head>
    <body>
    <h1>JavaScrip t Business Cards</h1>
    <p>The Script Begins Here.</p><hr>
    <script language= "JavaScript " type="text/javascript" src="Print_Card _Modified.js">
    </script>
    <p>The End of the Script.</p>
    <script language="JavaS cript" type="text/javascript">
    //Adding a function to change sting appearance
    function addHead(level){
    html ="h" + level;
    text = this.toString() ;
    start = "<" + html + ">";
    end= "</"+ html + ">";
    return start + text + end;
    }
    Sting.prototype .heading = addHead;
    document.write( "this is modified text".heading(1 ));
    </
    script>
    </body>
    </html>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    there is no function Sting() defined.

    isn’t this a bit over-complicated?

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      You probably meant to use String and not Sting. And yes, I agree, this is a convoluted way of getting this done.

      Comment

      • Brian Connelly
        New Member
        • Jan 2011
        • 103

        #4
        Thanks for the input. It works after I corrected the Sting to String. Im in the learning stage...so everything I do will most likely be convoluted. If you have any other suggestions for me please fill free to suggest. Anyway thanks for the help...It was driving me nuts!

        Comment

        • Brian Connelly
          New Member
          • Jan 2011
          • 103

          #5
          Im learning...ever ything might turn out over-kill! Thanks for the help.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            If you have any other suggestions for me please fill free to suggest.
            Code:
            elem.innerHTML = "<h1>" + text + "</h1>";

            Comment

            Working...