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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:59:57+00:00 2026-05-12T19:59:57+00:00

I want to detect and replace tab characters in a bit of HTML like

  • 0

I want to detect and replace tab characters in a bit of HTML like this:

<code>
  something
  {    something else
  }
</code

Right now, I am using something like this:

$(this).html(replaceAll(trim($(this).html()), "\t", "&nbsp;&nbsp;&nbsp;"));

But IE, in all its cleverness, changes tab characters into spaces, and so doing the above is useless. Does anyone know how I can detect tab characters in the HTML source with javascript for IE?

  • 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-05-12T19:59:57+00:00Added an answer on May 12, 2026 at 7:59 pm

    So, jmaglasang gave me a good idea. He said IE respects whitespace in a pre tag. So, I thought why not insert a pre tag with javascript, read the html, then remove the pre tag afterward. It works but theres a catch – you have to use a setTimeout callback. Heres the code:

    $("code").each(function()
    {   $(this).wrap("<pre></pre>");
        var element = $(this);
    
        setTimeout(function()   // read the html
        {   var x = element.html().split("");
            for(n in x)
            {    alert(x[n].charCodeAt(0) + " '" + x[n] + "'");
            }
        }, 0);
    });
    

    The setTimeout is neccessary because for some reason, IE waits to re-render the html until after all the javascript finishes running. Incidentally, it also waits to execute any callbacks issued by setTimeout. I wish I knew how I could force IE to render the html immediately… If anyone knows I’d definitely appreciate it.

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

Sidebar

Related Questions

I want to know if it's possible to do something like this: `readfile(base64_decode_only_img_src_tags(mypage.html)); I've
I want to extract variables from math expression using c#. I wrote this code
I want to detect faces on camera previews. I saw this example in OpenCV
I want to detect users' screen size and pass this into a charting application
I want to detect the presence of a scroll bar in a DIV using
So in my code I want to detect if my login page is being
This is a easy question,but I just don't get it. I want to detect
I want to detect when the right shift key is released on a form
I'm trying to write a search and replace regex that will detect whether HTML
I want Detect the largest number in inputs and done alert for it, How

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.