---
title: "How to write messages to the screen without using \"document.write()\"?"  
description: "How to write messages to the screen without using \"document.write()\"?"  
author: "Amit Singh"  
published: 2011-03-18  
updated: 2020-09-18  
canonical: https://www.mindstick.com/interview/536/how-to-write-messages-to-the-screen-without-using-document-write  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# How to write messages to the screen without using "document.write()"?

When the method showStatus is invoked it will change the content of the span.\
Example:\
function showStatus(message) {\
var element = document.getElementById("mystatus");\
element.textContent = message; //for Firefox\
element.innerHTML = message; //for IE (why can't we all just get along?)\
return true;\
}\
<span id="mystatus">Test. </span>

## Answers

### Answer by Amit Singh

When the method showStatus is invoked it will change the content of the span.\
Example:\
function showStatus(message) {\
var element = document.getElementById("mystatus");\
element.textContent = message; //for Firefox\
element.innerHTML = message; //for IE (why can't we all just get along?)\
return true;\
}\
<span id="mystatus">Test. </span>


---

Original Source: https://www.mindstick.com/interview/536/how-to-write-messages-to-the-screen-without-using-document-write

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
