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 9255215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:39:56+00:00 2026-06-18T11:39:56+00:00

This is probably very easy to do, but its been quite some time since

  • 0

This is probably very easy to do, but its been quite some time since I last used JavaScript, and I cant for the life of me remember how to do this (yes, I searched first, but found nothing that could help me).

Essentially I want to render this as a HTML blog post using a function:

<html>
<head>
<style>
body
{
background-color:#ffa500;
}

#blogElement
{
background-color: #fff;
margin-left:auto;
margin-right:auto;
width:70%;
}
</style>
</head>

<body>

<div id="mainContent">
    <div id="blogElement"></div>
</div>

<script>
var myBlogPosting = {  
  title:    "Google launches underwater Street View",
  image:    "1.jpg",
  author:   "Xeni Jardin",
  bodyText: "<p>Today Google Maps unveils a new Street View feature: " +
            "underwater panoramic views of six special sea spots. " +
            "The idea is to create a virtual map of the oceans, " +
            "documenting the state of fragile ecosystems as they " + 
            "change over time, and sharing a vivid experience of " + 
            "part of our world that few humans get to see up close " + 
            "and in person, in real life.</p>" +
            "<p>The ocean collection on Google Street View is now " + 
            "available at maps.google.com/ocean, and includes coral " + 
            "reefs and the creatures who live in them, in Australia, " + 
            "the Philippines and Hawaii.</p>",
  link:     "http://boingboing.net/2012/09/25/google-launches-underwater-str.html",
  ranking:  "3",
}

function CreateBlogHtml(blogpost)
{
   return "<h1>"+blogpost.title+"</h1>"+
        "<img src="+blogpost.image+" />"+
        "<p>Author: "+blogpost.author+"</p>"+
        blogpost.bodyText+
        "<a href=\""+blogpost.link+"\">Read more</a>"+
        "<p>Ranking: "+blogpost.ranking+"</p>";
}

document.write(CreateBlogHtml(myBlogPosting));

</script>
</body>
</html>

This is probably one of those things where I’ll slap myself in the face the moment it comes to me

  • 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-06-18T11:39:58+00:00Added an answer on June 18, 2026 at 11:39 am

    Your question is not clear enough, there are many ways to do what you want.

    One version would write the content on the fly

    <div id="blogElement"></div>
    <script>
    function CreateBlogHtml(blogpost)
    {
       return "<h1>"+blogpost.title+"</h1>"+
              blogpost.bodyText+
              "<a href=\""+blogpost.link+"\">Read more</a>";
    }
    
    document.write(CreateBlogHtml(myBlogPosting)); 
    </script>
    

    Another version would fill a HTML element

    <div id="blogElement"></div>
    <script>
    function CreateBlogHtml(blogpost)
    {
       return "<h1>"+blogpost.title+"</h1>"+
              blogpost.bodyText+
              "<a href=\""+blogpost.link+"\">Read more</a>";
    }
    
    
    function ShowBlogPost(blogpost)
    {
        document.getElementById("blogElement").innerHTML=CreateBlogHtml(blogpost))
    }
    
    
    ShowBlogPost(myBlogPosting));
    </script>
    

    You could also create a version which fills an element per field in the blog object.
    JQuery will give you many additional options to realise what you want.

    Beware: These examples are vulnerable to HTML injection. Please read up on this if you don’t know what this means.

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

Sidebar

Related Questions

This is probably very easy to do but for some reason I can't seem
This is probably very easy but I cant get it to work as I'd
k this is probably something very easy but for some reason i am getting
Very quick, and probably easy question... but its left me stumped for the last
This is probably a very easy question to answer, but for the life of
This is probably very easy, but it's Monday morning. I have two tables: Table1:
this is probably very easy but I can't figure it out :) $('#myDiv').html('<a onclick=remove_item(variantId);>Remove</a>');
I'm sure this is possible -- and probably very easy -- but I can't
I have problem with margin. Probably its very easy to solve, but i dont
This is probably a very easy question, but I never really did web... so

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.