Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6002449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:58:47+00:00 2026-05-23T00:58:47+00:00

This little line of code here is from a shopping cart: <a href=javascript:; onclick=simpleCart.add(

  • 0

This little line of code here is from a shopping cart:

<a href="javascript:;" onclick="simpleCart.add( 'name=The Devil&#039;s Sneakers', 'price=10', 'shipping=0', 'quantity=1' );">Add To Cart</a>

Firebug’s console shows: “missing ) after argument list”. Clearly the ‘)’ isn’t missing! But I suspect it has something to do with the escaped char

&#039;

since the other similarly formatted links without apostrophes in the name= argument are working fine.

Thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:58:48+00:00Added an answer on May 23, 2026 at 12:58 am
    onclick="simpleCart.add( 'name=The Devil&#039;s Sneakers'...
    

    Is an HTML attribute with the apostrophe escaped at an HTML level. It is exactly the same as saying:

    onclick="simpleCart.add( 'name=The Devil's Sneakers'...
    

    with the obvious problem with the string closing too early. HTML-escaping doesn’t help you because the HTML-escape is only needed to encode the characters that are special to HTML. That would include a double-quote character but not a single quote, since you’ve used double-quotes to delimit the attribute value.

    The apostrophe isn’t special to HTML here, but it is to JavaScript. You need to use JavaScript string literal escaping, and in that kind of escaping you need backslashes:

    onclick="simpleCart.add( 'name=The Devil\'s Sneakers'...
    

    Either way, it’s clear that escapes inside other escapes are really confusing and this is another good reason not to use inline event handler attributes. Instead, in plain JavaScript:

    <button type="button" id="foo">Add to cart</button>
    <script type="text/javascript">
        document.getElementById('foo').onclick = function() {
            simpleCart.add("name=The Devil's Sneakers", 'price=10', 'shipping=0', 'quantity=1');
        };
    </script>
    

    (I used a button because what you’ve got isn’t a link that goes anywhere. You can style it to look like a link instead of a button if you prefer, but it’s better not to have a link if none of the normal affordances of links, like middle-click or right-click-bookmark make any sense.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a little problem with the following: When I execute this line: echo
This is a little confusing to explain, so bear with me here... I want
Having a little bit of trouble with this section of code: if(!empty($_POST['RemoveRequest']) && isset($_POST['RemoveRequest'])){
I have this line of code: delete_btn = uicontrol(rr_ops, 'Style', 'pushbutton', 'String', 'Delete Graphic',
This little piece of code has been a staple in a bunch of my
hi i have a little program here that gets a directory from the command
This is my first OOP php app and I'm getting a little stumped here...
I have this little function function makewindows(){ child1 = window.open (about:blank); child1.document.write(<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']),
I have this little script to toggle a contact form when a button is
I'm trying to be responsible with my DOM references in this little Flash 8/AS2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.