Archive

Archive for the ‘web’ Category

Unknown Runtime Error in Internet Explorer while using innerHTML

December 13, 2011 Leave a comment

This is one of those awesome “features” of the Microsoft browser. One which can send web developers of the deep end.

Seems this error may happen due to several reasons:

  • You are trying to put a block-level element inside an inline element like a div element inside a p element (see source 1)
  • You are trying to set a table’s innerHTML (see source 2)
  • You are trying to put a form element inside an element that is itself inside another form
By looking at those two sources you can easily fix the first two errors. On the third one i didn’t seem to find any sources for it so here it is.
I had a strange (read stupid) situation where i was trying to do the following
<form>
   <div id=”container”>
   </div>
</form>
<script type=”text/javascript”>
    <!–
    var obj=document.getElementById(‘container’);
    obj.innerHTML='<form>….. another form</form>’;
    //–>
</script>
Note that div is already inside another form tag. The code above will throw our URE friend since i am trying to put a form tag inside another form tag. Chrome and Firefox jump over this problem by doing some kind of code clean up on render.

In my case i chose to  replace the original form completely or avoid using the form tag in these situations. All together this seems like a design problem as situations like this should not occur in the first place.

Note that if you run into trouble with the prototype Ajax functions you might want to set the onException option in order to see what is really happening. Though in this case the exceptions isn’t particularly helpful since it only states : Unknown Runtime Error

 

Update:

If this happens to you when using prototype ajaxupdater, create your own ajaxreplacer that replaces the div instead of trying to set innerHtml.

Sources:

  1. http://blog.rakeshpai.me/2007/02/ies-unknown-runtime-error-when-using.html
  2. http://stackoverflow.com/questions/555965/javascript-replace-innerhtml-throwing-unknown-runtime-error#556020
Advertisements
Categories: web Tags: ,

FireFox keeps asking for Proxy Authentication

October 6, 2009 Leave a comment

I use firefox at work to do my browsing of the interwebz, for some stupid reason i recently ran into a problem where firefox kept asking me for the proxy authentication instead of saving the previous entered information. It would do this for every resource on a page. So when i opened a webpage i would have to click the damn ok button multiple times.
I smal search on google produce the following link : http://forums.mozillazine.org/viewtopic.php?p=3070251

If you don’t want to go reading the forums here is the TLDR solution – change network.negotiate-auth.allow-proxies property in about:config to false
This works for newer versions of firefox too.

Categories: web Tags: ,

Clear a form with javascript (prototypejs)

January 19, 2009 Leave a comment

The following snippet clears all fields in a form:

function apagarForm(formName) {
    $(formName).getElements().each(function(item) {
        if (item.name != "form_name" && item.type != "button" && item.type != "submit") {
            if (item.tagName == "SELECT") {
                item.selectedIndex = 0;
            } else if (item.type == "text") {
                Form.Element.clear($(item.id));
            } else if (item.type == "radio" || item.type == "checkbox") {
                item.checked = false;
            }
        }
   })
}

This uses prototype to iterate over the form fields.

Categories: web Tags: , ,