My website has always run smoothly with IE8, IE7, FF, Chrome and Safari. Now I'm testing it on IE9 and I'm experiencing a strange problem: in some pages, some tabular data renders incorrectly.
The HTML source is correct and all, and the row giving the problem changes every time I refresh the page (to tell the truth, the problem itself appears only in some refresh, not all).
Using the F12 Tool of IE, the table structure appears correct, there should be no empty TD after the TD containing M08000007448, but still it renders like this.
Moreover, if I use the F12 tool, with "select element by click" tool in the toolbar, and I try to click on the empty space between M08000007448 and 19 , it selects the TR, not a "hidden td".
I'm having this table rendering problem also in some other table in the application, anyone experiencing something like this? It happens only in IE9 :(
I don't know if it's important, but the page is made with ASPNET (webforms) and use Jquery and some other JS plugin.
I tried to save the page (with images) and open it in local with IE9, but the problem never occurs. (Of course I checked all the table structure and it's ok. Header and all rows have the eact same number of TD's, with the right number of colspan when necessary).
I have exactly the same problem as well. you may want to read this https://connect.microsoft.com/IE/feedback/details/649949/innerhtml-formatting-issues-on-very-large-tables
YOu can remove the space inbetween td by using javascript if your html is returned from ajax, then from the response, you replace it with
response_html = response_html.replace(/td>\s+<td/g,'td><td');
$('#table').html(response_html);
I had the same exact issue populating a table using jquery templates. I kept having 'ghost' <td>'s on larger datasets (300+) only in IE9. These <td>'s would push the outer columns outside the boundries of my table.
I fixed this by doing something really silly; removing all the spaces betwen the <td> start and end tags and left justifying the HTML markup pertaining to my table. Basically, you want all of your <td> </td> on the same line, no spaces.
Example:
<table>
<tr class="grid_customer_normal">
<td>${primary}</td>
<td>${secondary}</td>
<td>${phone}</td>
<td>${address}</td>
</tr>
</table>
The solution given #Shanison helps only partially but the problem persists if there are spaces between any of the other elements that can be part of the table content model like thead, th etc.
Here is a better regex devised by my Lead at work.
if (jQuery.browser.msie && jQuery.browser.version === '9.0')
{
data = data.replace(/>\s+(?=<\/?(t|c)[hardfob])/gm,'>');
}
covering all table, caption, colgroup, col, tbody, thead, tfoot, tr, td, th elements.
Note: jQuery.browser was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. Please try to use feature detection instead.
I fixed this issue by removing the whitespace:
var expr = new RegExp('>[ \t\r\n\v\f]*<', 'g');
var response_html_fixed = data.replace(expr, '><'); //A disgusting hack for ie9. Removes space between open and close <td> tags
$('#treegrid-data').replaceWith(response_html_fixed);
IE Blog mentions a new tool today called the Compat Inspector script to help troubleshoot IE 9 rendering incompatibility. It may help troubleshoot your issue.
http://blogs.msdn.com/b/ie/archive/2011/04/27/ie9-compat-inspector.aspx
I was having that problem too.
It occured to me, that width attribute in td/th tags causng this problem.
Changed it to style="width: XXpx" and problem is solved :)
I ran into this problem as well and I realized that it happened when I was directly putting text in <td> elements. I'm not certain whether it's a standard or not but after wrapping any text in <span> elements, the rendering issues disappeared.
So instead of:
<td>gibberish</td>
try:
<td><span>gibberish</span></td>
Found a very useful script to prevent unwanted cells in your html table while rendering.
function removeWhiteSpaces()
{
$('#myTable').html(function(i, el) {
return el.replace(/>\s*</g, '><');
});
}
This javascript function you should call when the page loads (i.e. onload event)
Late answer, but hopefully I can help someone with this.
I experienced the same problem when debugging in IE9. The solution was removing all whitespaces in the HTML code.
Instead of
<tr>
<td>...</td>
<td>...</td>
</tr>
I had to do
<tr><td>...</td><td>...</td></tr>
This seemed to solve the problem!
This is the very serious bug in IE9. In my case removing only white spaces between different td was not sufficient, So i have removed spaces between different tr also. And it is working fine.
I had similar problem with ie-9 when rendering dynamic table.
var table = $('<table><tr><td style="width :100"></td></tr></table>');
when rendered translates to...
<table><tbody><tr><td style="width :100px"></td></tr></tbody></table>
this works perfectly fine in ie=10 chrome safari...
// but for ie-8 it renders to... with a style attr in my case
<table><tbody><tr><td ></td></tr></tbody></table>
you need to write 100px instead of 100.
Having same formatting issue with ie9, and a new issue in ie11 where it formats correctly but takes 25-40 seconds to render a table of about 400 rows and 9 columns. It has the same cause, whitespace inside the tr or td tags.
I'm displaying a table that is created by the rendering of a partial view from an AJAX call. I decided to BFH it on the server by removing the whitespace from the rendered partial view, using a method posted here: http://optimizeasp.net/remove-whitespace-from-html
This is his solution copied in-toto:
private static readonly Regex RegexBetweenTags = new Regex(#">(?! )\s+", RegexOptions.Compiled);
private static readonly Regex RegexLineBreaks = new Regex(#"([\n\s])+?(?<= {2,})<", RegexOptions.Compiled);
private static string RemoveWhitespaceFromHtml(string html)
{
html = RegexBetweenTags.Replace(html, ">");
html = RegexLineBreaks.Replace(html, "<");
return html.Trim();
}
And here is a method that returns a partial view as a string, stolen from another SO answer:
public string RenderPartialViewToString(string viewName, object model)
{
this.ViewData.Model = model;
try
{
using (StringWriter sw = new StringWriter())
{
ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(this.ControllerContext, viewName);
ViewContext viewContext = new ViewContext(this.ControllerContext, viewResult.View, this.ViewData, this.TempData, sw);
viewResult.View.Render(viewContext, sw);
return RemoveWhitespaceFromHtml(sw.ToString());
}
}
catch (Exception ex)
{
//logger here
}
}
It takes a bit of time, but less than a second to render a table of about 400 rows, which for my purposes is good enough.
I had this problem sometimes on tables generated by Knockout. In my case I fixed it using the jQuery solution found here
jQuery.fn.htmlClean = function() {
this.contents().filter(function() {
if (this.nodeType != 3) {
$(this).htmlClean();
return false;
}
else {
this.textContent = $.trim(this.textContent);
return !/\S/.test(this.nodeValue);
}
}).remove();
return this;
}
I had the same issue with KendoUI grid in IE10. I was able to force IE to rerender missing table cells with this hack:
htmlTableElement.appendChild(document.createTextNode(''));
Appending an empty textNode makes IE to rerender the whole table.
Related
I have found some strange behavior of IE 10. I guess it's bug, but I didn't found any description of it here or in the Google, so I am not such sure about it.
The deal is a problem with editable "pre" tag. Actually, there are two problems.
It's reproducible in JSFiddler on the IE10:
<pre contentEditable="true">
some text, it's editable
text <label contentEditable="false">it's not!!! test</label>
some text
</pre>
Here is a link with demo I recorded on the JSFiddler (i can't attach images due to low reputation, so I give you a link only).
Some description:
I can't add text to the end of the line. When I set a caret to the end and start typing something, text appears on the new line. I can't reproduce this on the other browsers (IE 8-9, 11 works fine). I don't know what the problem is. BUT when I modify text on the same line, but in the middle of line, after that - everything works perfect (as expected) and I can add text to end.
I can edit uneditable children block. As you can see on the demo, I can easily move cursor between first and second letter of uneditable block (and ONLY between them, I can't move forward) and change the text. And yes, it works fine in other browsers (I can't edit anything inside block).
Can anyone confirm that it's a bug or I'm just doing something wrong?
If anyone knows any workarounds, please share.
Thank you all for help!
I guess I figured it out.
Yes, it's a bug with IE10, contentEditable tag and line ending \n. If you have all of them, so when you go to the end of the line IE10 put cursor after \n symbol, and when you try to enter some text - it occurs on the begging of new line.
Moreover, when you see that cursor is in the end of the line or it's in the begging of the next line, IE10 doesn't see any difference (you can see it visual, but internally - no difference).
After few days investigation, I didn't find way to overcome this behavior (or way to differ these states).
So, I just replace all \n with <br />:
if (IE.isTheBrowser && IE.actualVersion === 10) {
var newLineFix = new RegExp("\n", "g");
s = s.replace(newLineFix, "<br />");
}
That's it! Bug doesn't occur anymore.
Second issue about editing uneditible children. I just write the following fix (occurs when user enter a symbol):
function getOldRange() {
return document.selection.createRange();
}
function onKeyPress() {
if (getOldRange()) {
var oldRange = getOldRange();
if (IE.isTheBrowser && IE.actualVersion === 10) {
var parent = oldRange.parentElement();
if (parent.getAttribute("contentEditable") === "false") {
var newRange = document.createRange();
newRange.setStartAfter(parent);
newRange.setEndAfter(parent);
var selection = getNewSelection();
selection.removeAllRanges();
selection.addRange(newRange);
}
}
...
}
}
I know that it's a bit of messy code, but it works just perfect for me!
Hope it helps somebody.
In our MVC5 project there is a page where user can check multiple assets.
Each asset is represeneted by checkbox and name.
When there are a lot of assets (about 800-1000) Chrome getting extremely slow. It's even sometimes show message that "page is unresponsible".
It looks like this:
- page is partially rendered and stucked on DIV with checkboxes
- then there is delay 30-40-50 sec. Sometimes error message
- DIV with checkboxes rendered and rest of the page rendered too
In FF and IE it's ok.
Thanks in advance
I agree that it's not a good user experience, but at the current stage I need to solve this problem.
Here is markup (this div is 4 level nested):
<div class="list">
#for (int i = 0; i < Model.Items.Count; i++)
{
<text>
#{var cid = Guid.NewGuid().ToString();}
#Html.HiddenFor(m => Model.Items[i].Id)
#Html.CheckBoxFor(m => Model.Items[i].Selected, new { id = cid })
<label for="#cid">#Trakopolis.WebSite.AppHelper.GetLocalizedString(Model.Items[i].Name)</label><br />
</text>
}
</div>
You could try to use javascript for this where everything is in plain text with data attributes and on click, input element is temporarily added, the input element takes the input, sends it to the server (or saves it in indexeddb for async using a service worker) and removes itself or waits for next input.
<td id=“unique-id1” data-url=“/action” data-name=“InputName”>data</td>
Same problem with Safari, I suspect a webkit bug. Any page with hundreds or thousands of input fields will be very very slow to navigate or edit.
See Why does Safari Mobile have trouble handling many input fields on iOS 8
We have a page with some tables with 300 rows, each row has several cells and each cell is editable (input).
Workaround given in link above works nicely.
Looks like Chrome not uses closing tags for checkboxes dropdown markup for and <br> that is somehow forces additional browser internal checks and as result slow page rendering in comparison to IE and FF browsers(that are using closing tags). To avoid Chrome slow loading because of <br /> tags you may use opening and closing <div> instead and speed up page a bit, but I'm not sure whether <input> elements may be replaced somehow.
I'm experiencing a major bug in IE 11 (latest version 11.0.9600.16521 on Windows 7). When on any form if I open a select dropdown all the other form fields on the page freeze. I can 'unfreeze' them by adjusting the Window size (causing a redraw). This seems to happen on any form what-so-ever.
To reproduce:
Open IE 11.0.9600.16521
Go to http://www.wikipedia.org/
Select any language from the language dropdown
Result:
language dropdown does not appear to get updated on the screen
the search box appears to be frozen - i.e. focus on select box and start typing but no text appears. However if you adjust the window size the form fields are updated and go back to working as normal (until you interact with another select element)
I can't find much in Google for this issue so maybe it's just something specific to my settings. Only thing that sounds somewhat similar to what I'm experiencing is this: http://connect.microsoft.com/IE/feedback/details/806679/ie-11-desktop-selecting-an-item-from-a-drop-down-list-on-a-webpage-causes-the-tab-to-crash. Anyone else able to reproduce this?
I had a similar issue with IE11 that turned out to be any modification to the .text property of an SELECT-option element. I eventually found the "hint" on stackoverflow here
How to fix IE select issue when dynamically changing options.
In my case I use straight JavaScript, and with so many inter-dependent SELECT boxes had to come up with a generic solution, so my solution was to intercept (defineGetter) assignment to any .text property of an HTMLOptionElement, and set a 1 ms timer to perform an add element and remove element as in the referenced post that is titled "I have the fix. We have to add and remove options list to trigger the rendering in IE8." Notice the reference to IE8, AFAIK IE has had several issues with SELECT boxes since at least IE7, possibly earlier.
So the code I added to one of my global scripts is as follows:
try { var IE11; // IE10 and IE11 removed ActiveXObject from the window object but it can still be instantiated
IE11 = new ActiveXObject('MSXML2.DOMDocument.6.0');
IE11 = null;
if (typeof(HTMLOptionElement) != "undefined") {
try { HTMLOptionElement.prototype.__defineSetter__(
'text',
function(original) {
return function(newValue) { var sel;
original.call(this, newValue);
if (!(sel=this.parentElement).fixIE) sel.fixIE = window.setTimeout(_fixIE_(sel), 1);
}
}(HTMLOptionElement.prototype.__lookupSetter__('text')));
} catch(e) {};
}
} catch(e) {}
}
// IE11 broke SELECT boxes again, modifying any options .text attribute "freezes" the SELECT so it appears disabled
function _fixIE_(selBox) {
return _fixIE_;
function _fixIE_(){ var lc = selBox.options.length;
selBox.options.add(new Option('',''));
selBox.options.remove(lc);
selBox.fixIE = undefined;
}
}
Phil
Go to programs
Then widdcom folder
Right click bttray
Go compatibility
Tick run as admin
Restart
I had the same problem in IE 11 on Dell Windows 7.
It was solved by turning off hardware rendering in IE, as you suggested in your link.
The reason I want to use the together is that I want to hide the content like display: none does, without leaving any whitespace as visibility: hidden does.
At the same time I want the hidden content not to be copied when the user copies the entire table from the webpage, not because it is sensitive information but because the user hid the field and therefore doesn't want it copied. visibility: hidden doesn't copy but display: none does, so I have quite a dilemma.
Anyone know a solution?
Edit:
What I ended up doing was just what was suggested, save the information as Javascript (as it is not sensitive information anyways) and create/remove dynamically with Javascript.
I do not think giving the element visibility: hidden prevents the user copying the information in the table, although this may be browser specific behavior. Have a look at the test I've set up: http://jsfiddle.net/a9JhV/
The results from Firefox 3.6.8 on Windows 7 is
Copy ME! Don't copy me :( Copy ME! Copy ME!
Copy ME! Don't copy me :( Copy ME! Copy ME!
Which doesn't work as expected.
I've cooked up some code, it took the quite a bit work of cook up... have a look here: http://jsfiddle.net/a9JhV/7/
It uses jQuery to hide and show the table columns - actually removes them from the DOM, not just play around with their visibility and whatnot. Whee!
Why not remove the node from the page? You could accomplish this by using:
<script type = 'text/javascript' language = 'JavaScript'>
document.getElementById('yourDivId').innerHTML = '';
//OR
document.removeChild(getElementById('yourDivId')); //(I think this is right...document might need to be replaced by the div's parent)
</script>
You should remove the "hidden" DOM object using javascript and then recreate it again if user wants it back. Data from deleted records can be stored in session storage or hidden inputs for example.
If you want elements HIDDEN from the source, place them in a separate text file and load it using an ajax-like call... this will prevent the html from being in the source.
If you place a clear image OVER the content they also will not be able to highlight it easily (and by using javascript you can likely disable their ability to do a ctrl+a)
hope that helps!
It's a good idea to create an object to represent the table:
var myTable = function(tableName){
// If you want to assign columns dynamically you could create this.addColumn();
this.Columns = new Array(
new Array("row1","row2","row3","row4"),
new Array("row1","row2","row3","row4")
);
this.reBuild = function(){
for (col in this.Columns){
for(row in this.Columns[col]){
// put the cell in the table
}
}
};
};
I didn't test this code, it should just illustrate the gist of storing and building a table.
I'm currently using the Mootools Element constructor method to dynamically add a new row into a table.
function newPermission(somedata) {
var newUserPerm = new Element('tr', {
'html': '<td>foo</td><td>bar</td>'
});
newUserPerm.inject('permissions_table');
}
However, upon checking the resulting code, the following HTML string gets added to the table:
<tr>foobar</tr>
I'm sure there's some way to send the HTML tags as well, but I can't find much on it here, except one other question, in which the user had an outdated ver. of Mootools...
this has been fixed in mootools 1.3 beta and i think only affects tables (otherwise html setters via element constructors are fine) - in the mean while, do not set the html through the element constructor but set the it after you create the TR:
var tr = new Element('tr').inject(document.id("foo").getElement("tbody"), "top");
tr.set("html", '<td>foo</td><td>bar</td>');
here it is working as you had it in 1.3: http://www.jsfiddle.net/dimitar/ALsBK/
and here it is breaking in 1.2.4: http://www.jsfiddle.net/dimitar/ALsBK/1/
and working in 1.2.4: http://www.jsfiddle.net/dimitar/ALsBK/2/