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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:38:24+00:00 2026-06-16T18:38:24+00:00

I have a input text field where the app user can enter the document

  • 0

I have a input text field where the app user can enter the document description.
On a page load event I check if this input field is empty.
If it is empty, I insert the following text and change the style to italic and red-

Please enter a description for this document

I have event listeners for onblur and onfocus events while the page is active.

Basically if the user clicks into the text field, I change the CSS back to normal and black and revert the value to an empty string.

Onblur I’ll check the contents – if it’s empty I’ll revert back to the "Please enter…" message and the red/italic CSS.
If it’s not empty I’ll keep the user input as is.

The problem I’m having is that after the initial page load, if the user goes away to another page to do a lookup and then comes back and THEY DID NOT CHANGE the document description, so it is still saying "Please enter…", the red and italic CSS does NOT take affect.

I am experiencing this in Firefox across all browsers.

Here is how I am register the page onload events across the browsers –

//Microsoft Internet Explorer Browser - iFrame event register
if (navigator.appName.indexOf("Microsoft") != -1) {
  var frame = getPortlet();

  frame.contentWindow.location.replace('${channelUrl}');
  var prevPortletLoadEvent = frame.onload ? frame.onload : function () {};
  var refresh = function() {
    prevPortletLoadEvent();
    resizePortletContainer();
    attachTinyButtonListener();
    attachDocumentDescriptionListener();
    enforceDocumentDescriptionStyleIfNecessary();
  };

  if(frame.attachEvent) { frame.attachEvent('onload', refresh); } //IE browsers before version 9
  else  { frame.addEventListener('load', refresh, false); }
}

//All other major browsers - iFrame event register
else {
  var frame = getPortlet();
  var prevPortletLoadEvent = frame.onload ? frame.onload : function () {};
  frame.onload = function () {
    prevPortletLoadEvent();
    resizePortletContainer();
    attachTinyButtonListener();
    attachDocumentDescriptionListener();
    enforceDocumentDescriptionStyleIfNecessary();
  };

  var prevPortletResizeEvent = frame.onresize ? frame.onresize : function () {};
  var onresize = function () {
    prevPortletResizeEvent();
    resizePortletContainer();
    attachTinyButtonListener();
    attachDocumentDescriptionListener();
    enforceDocumentDescriptionStyleIfNecessary();
  };
}

And here is the enforeDocumentDescriptionStyleIfNecessary –

function enforceDocumentDescriptionStyleIfNecessary() {

  var  efrm  = getPortlet();
  var  e_doc = efrm.contentDocument ? efrm.contentDocument: efrm.contentWindow.document;
  var  e_docElement = e_doc.getElementById('document.documentHeader.documentDescription');
  if (e_docElement.value == 'Please enter a description for this document') {


    e_docElement.style = 'italic';
alert("1");    
    e_docElement.color = 'red';
alert("2");
  }
}

The code gets executed on the page load.
The alert boxes show up displaying 1 and 2 and I can visually inspect the html for this element after each alert box).

The style is not being added! It is as if this code is executed but ignored…

What am I doing wrong?

  • 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-16T18:38:25+00:00Added an answer on June 16, 2026 at 6:38 pm

    You aren’t correctly setting the style of the element. It should be:

    e_docElement.style.fontStyle = 'italic';
    e_docElement.style.color = 'red';
    

    You will always need to use the style property to modify the inline css of an element.

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

Sidebar

Related Questions

I have this text input field on a web page. User types in item
In my iPhone app I have a settings page where a user can enter
In my web app, users can input text data. This data can be shown
I have a text field within my app. When a user inputs text I
I have an input (text field) in update panel, and it autopostbacks after each
I have an input text field, which has a value something by default, but
I have an input text field which has style: visibility: visible or style: visibility:
I have a jQuery jPicker colorpicker that is bound to an input text field
I have a text input field like text box or text area. I want
I have 1 div and 1 text input field, the div is visible and

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.