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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:48:16+00:00 2026-06-11T21:48:16+00:00

<script> var obj = {{ data|raw }} document.body.innerHTML = ; document.body.appendChild(document.createTextNode(JSON.stringify(obj, null, 4))); </script>

  • 0
<script>
    var obj = {{ data|raw }}
    document.body.innerHTML = "";
    document.body.appendChild(document.createTextNode(JSON.stringify(obj, null, 4)));  
</script> 

This is the body of my html file. The problem is that when I make a new css file – metadata.css just for this html file and it contains this:

body {
    white-space: pre-wrap; 
    width: 770px;
} 

everything works. But I don’t need this new file. So I tried to change my html to this:

<div class="metadata">
    <script>
        var obj = {{ data|raw }}
        document.body.innerHTML = "";
        document.body.appendChild(document.createTextNode(JSON.stringify(obj, null, 4)));  
    </script> 
</div>

and add the style for the div in the css file where is all my css and it became this:

body {
    text-align: center;
}

table{
    width: 100%;
    border-collapse:collapse;
    margin: 20px 0px;
}

table,th, td{
    border: 1px solid black;
    font-size: 17px;
}

th {
    background-color: #D3D3D3;
    font-weight: bold;
}

td {
   padding: 3px 5px; 
}

a.pagination {
    margin: 9px;
}

span {
    font-weight: bold;
}

.find_page {
    margin: 20px;
}

form input {
    width: 50px;
}

.metadata {
    white-space: pre-wrap; 
    width: 770px;
    text-align: left;
}

but the problem is that in this way, it doesn’t work – I think that the div is not styled at all. Can you please help me to fix it?

  • 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-11T21:48:18+00:00Added an answer on June 11, 2026 at 9:48 pm

    The problem is that your javascript is not targeting the container it’s in.

        document.body.innerHTML = "";
        document.body.appendChild(document.createTextNode(JSON.stringify(obj, null, 4)));  
    

    is going to target the body of the document since it’s using document.body, and not care about where the code is defined (and therefore the class of the container is entirely discarded…actually erased by the innerHTML = "" statement. What you’d be looking for is document.write which will output in the place of definition (and with no clearing statement).

     document.write(document.createTextNode(JSON.stringify(obj, null, 4)));  
    

    This in general should be replaced by explicitly tageted selection and unobtrusive JavaScript when you start to do anything more than one-off code.

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

Sidebar

Related Questions

I made this Greasemonkey script: var maxpi = 250; var p1 = /html/body/div/div[2]/div/div[2]/table[2]/tbody/tr[1]/td[11]; var
In Firefox's and Chrome's consoles, this works (alerts script content): var script = document.createElement(script);
I am trying to do something like this: var data = $('#upTar').contents(); $(#fileRes).html(data); Where
For this piece of script: var die = Math.floor(Math.random()*6 + 1); It's expected to
I have this jQuery script var dataString = class_id=+class_id; $.ajax({ type: POST, url: page.php,
I have an array that was populated by this script : var imgs =
I'm trying to pass this to a PHP script through AJAX: var answers={}; for
I am using this code: <script type=text/javascript> var id = <?php if(is_numeric($_GET['id'])) print $_GET['id'];
my code http://jsfiddle.net/4Ub95/ <!DOCTYPE html> <html> <head> <title>example</title> </head> <body> <script src=libs/jquery-1.7.2.js></script> <script> $(function(){
my script: var Url = 'http://readonline.egscans.com/Remnant/Chapter_036_[END]'; var response = UrlFetchApp.fetch(Url).getContentText(); I get this error

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.