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

  • SEARCH
  • Home
  • 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 7031333
In Process

The Archive Base Latest Questions

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

I am trying to put share buttons into a website. I found a good

  • 0

I am trying to put share buttons into a website. I found a good site called AddThis, and here is what I was able to put together:

<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style addthis_32x32_style"
  addthis:url="http://example.com"
  addthis:title="An Example Title"
  addthis:description="An Example Description">
  <a class="addthis_button_facebook"></a>
  <a class="addthis_button_twitter"></a>
  <a class="addthis_button_google_plusone_badge"></a>
  <a class="addthis_button_linkedin"></a>
  <a class="addthis_button_compact"></a>
  <a class="addthis_counter addthis_bubble_style"></a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f0a28da71ac4a61"></script>
<!-- AddThis Button END -->

I can paste all of that into the html page, and it displays correctly. However, the link, title, and description need to be variables, not “http://example.com&#8221;. The user interface is based on Javascript, and gives users articles to rate in succession. The link, title, and description variables are story_link, story_title, and story_description.

I tried putting all of that into a variable in Javascript:

var story_link_href = '<a href="' + story_link + '" target="_blank" >Read more...</a><br /><br /><!-- AddThis Button BEGIN --><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url="' + story_link + '" addthis:title="' + story_title + '" addthis:description="' + story_description + '"><a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone_badge"></a><a class="addthis_button_linkedin"></a><a class="addthis_button_compact"></a></div><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f0a28da71ac4a61"></script><!-- AddThis Button END -->';

The problem with this is, the entire article text along with the share buttons are inside <p> tags. As far as I can tell, <div> tags don’t work inside <p> tags.

I know almost nothing about Javascript and HTML, so everything is just a guess. I can either paste the first bunch of code straight into HTML and have a static link, or not have anything show up if I paste it into Javascript. Neither works the way it should.

Is there is a way to pass the “story_link”, “story_title”, and “story_description” variables into HTML, and keep passing new information as new articles come up, or is there another way to integrate that code into Javascript, with having the <p> still surrounding everything?

  • 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-28T00:47:24+00:00Added an answer on May 28, 2026 at 12:47 am

    <div>s inside <p> is not valid HTML, but they do work.

    If you want to avaoid <div> inside <p>, replace “div” tags in addThis to “span” like below:

    <!-- AddThis Button BEGIN -->
    <span class="addthis_toolbox addthis_default_style addthis_32x32_style"
      addthis:url="http://example.com"
      addthis:title="An Example Title"
      addthis:description="An Example Description">
      <a class="addthis_button_facebook"></a>
      <a class="addthis_button_twitter"></a>
      <a class="addthis_button_google_plusone_badge"></a>
      <a class="addthis_button_linkedin"></a>
      <a class="addthis_button_compact"></a>
      <a class="addthis_counter addthis_bubble_style"></a>
    </span>
    <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f0a28da71ac4a61"></script>
    <!-- AddThis Button END -->
    

    It’s not working because you can’t write script tag the way you have done. You should always split the script tag or append it to the body as below:

    var story_link = "http://google.com",
        story_title = "Title",
        story_description = "Description";
    
    var story_link_href = '<a href="' + story_link + '" target="_blank" >Read more...</a><br /><br />'
        +'<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url="'
        + story_link + '" addthis:title="' + story_title + '" addthis:description="' + story_description 
        + '"><a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone_badge"></a><a class="addthis_button_linkedin"></a><a class="addthis_button_compact"></a></div>';
    
    
    var atscript = document.createElement( 'script' );
    
    atscript.type = 'text/javascript';
    atscript.src = 'http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f0a28da71ac4a61';
    document.body.appendChild(atscript);
    document.write(story_link_href)
    

    Here is an update. Use this in place of the code you posted in your question. Discard above JS code I posted in this answer. I’m sure the below code will work.

    var story_link_href = '<a href="' + story_link + '" target="_blank" >Read more...</a><br /><br />'
        +'<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url="'
        + story_link + '" addthis:title="' + story_title + '" addthis:description="' + story_description 
        + '"><a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone_badge"></a><a class="addthis_button_linkedin"></a><a class="addthis_button_compact"></a></div><scr'+'ipt type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f0a28da71ac4a61"></scr'+'ipt>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying put an if statement directly into a select field in rails, with
Im trying to put an html embed code for a flash video into the
I trying to put together an Android app that will take a picture and
We're trying to put together kiosk solution where we can charge people by hour
I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it
I am trying to put some distributed caching into play, I'm using this indeXus.Net
I'm trying to put a Message back into an MSMQ when an exception is
I am trying to put a requirement together for a new environment to consist
Hello all i have a button i am trying to let users share a
I am trying to put together a mysql query, that links 3 tables together.

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.