Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2010
    Posts
    27
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Error in JavaScript

    I was working on this script to change text with javascript and I ran into a problem. The code goes like this:

    PHP Code:
    <area shape="rect" coords="128,174,256,203" href="#" onClick="document.getElementById('content').innerHTML='<p class=first>Welcome to the first release of my 
    Now every time I use an apostrophe in a word then when I click the link that corresponds to that writing, it doesn't do anything. Here's the link to my website: http://bittipiilo.com/msx/
    By default you are on the Home tab. Then when you click either Gallery or Services and try to go back to Home, nothing happens. Can someone help me?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,901
    Thanks
    79
    Thanked 4,423 Times in 4,388 Posts
    To put an apostrophe inside of a string delimited by apostrophes, use \'

    To put a quote inside of a string delimited by quotes, use \"

    Code:
    var a = 'I\'m here!';
    var b = "He said, \"I'm here!\"";
    
    It never hurts to use the \' or \" if you aren't sure:
    
    var c = "I\'m here!";
    var d = 'He said, \"I'm here!\"';
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    The Infection (12-29-2010)

  • #3
    New Coder
    Join Date
    Nov 2010
    Posts
    27
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you so much. That's been bothering me for quite some time.


  •  

    Posting Permissions

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