How to Get Rid of Question Marks for Firefox in HTML

  • Share
  • Print this article

Question marks may be a part of some titles or subtitles in your Web pages. You can use JavaScript to detect the browser, and strip the question marks from the content if the browser is Firefox. The JavaScript language lets you create dynamic content based on browser type, so you can ensure any characters you do not want to show are removed from the content only in Firefox.

Instructions

    • 1

      Right-click the HTML window that contains your content. Click "Open With," then click the HTML editor you use to create and edit your sites.

    • 2

      Add this JavaScript function to detect if the user is using the Firefox browser:

      var browser = navigator.userAgent;
      var isfirefox;
      if ((/Firefox[\/\s](\d+\.\d+)/.test(browser)) {
      isfirefox = true;
      }

    • 3

      Remove question marks if the "isfirefox" variable returns true. The following JavaScript code removes the content from a div named "bodycontent":

      var originalcontent = document.getElementById("bodycontent")innerHTML;
      var removedcontent = originalcontent.replace("?", "");
      if (isfirefox) {
      originalcontent.innerHTML = removedcontent;
      }

    • 4

      Save the changes and open the page in Firefox and an alternative browser so you can see the JavaScript working for both browser types.

References

Comments

Featured
View Mobile Site