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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I have a few questions I want to ask

    This is code I am working on that declares variables (var yotta = 1e24; var zetta = 1e21; ...) and calls them using document.write(yotta); document.write(zetta); ... The thing is when the web page displays it does not display the variables but rather the document.write(yotta); I am wondering if my code is in the wrong part or if there is something I can do to correct this?

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    West Des Moines, Iowa
    Posts
    8,199
    Thanks
    38
    Thanked 1,092 Times in 1,088 Posts
    I are in the section that's talks about JSON and your not asking anything related to that. The document.write(yotta); document.write(zetta); tells me it's Javascript that your using. I need to see the code for the page. The JS at lest.
    Using document.write is not good. For an alternatives solution use innerHTML or innerTEXT, an example: document.getElementById('output1').innerHTML = 'Some text!';
    You could use createText
    Code:
    document.createElement('p');
    para.appendChild(document.createTextNode('Hello, '));

    If those work come back the tell us know. If it doesn't paste the code between [code] tags.

    And welcome to the forum, hope you do spend time here
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.

  3. #3
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    West Des Moines, Iowa
    Posts
    8,199
    Thanks
    38
    Thanked 1,092 Times in 1,088 Posts
    I are in the section that's talks about JSON and your not asking anything related to that. The document.write(yotta); document.write(zetta); tells me it's Javascript that your using. I need to see the code for the page. The JS at lest.
    Using document.write is not good. For an alternatives solution use innerHTML or innerTEXT, an example: document.getElementById('output1').innerHTML = 'Some text!';
    You could use createText
    Code:
    document.createElement('p');
    para.appendChild(document.createTextNode('Hello, '));

    If those work come back the tell us know. If it doesn't paste the code between [code] tags.

    And welcome to the forum, hope you do spend time here
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.

  4. #4
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    3,752
    Thanks
    5
    Thanked 539 Times in 525 Posts
    Quote Originally Posted by sunfighter View Post
    For an alternatives solution use innerHTML
    Which is as big a risk and as outdated as document.write

    Quote Originally Posted by sunfighter View Post
    or innerTEXT
    Which is non-standard, outdated, and technically supposed to be IE only. I think you meant to say textContent.

    Though document.createTextNode and one of the append/insertBefore methods is indeed a more proper approach since it goes straight to the DOM.

    But yeah, if document.write is being used, there's something horribly wrong with the entire codebase. This isn't 1997.
    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare, The 1980 ACM Turing Award Lecture
    http://www.cutcodedown.com


 

Tags for this Thread

Posting Permissions

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