Hey Everyone,

After scouring the web for a while with no resolution it seems it's time to ask someone for help.

So I've got this javascript code for a messaging system and here's what happens:

  1. User clicks a link to open a message
  2. A DIV is created using document.createElement()
  3. The DIV gets positioned and filled with its contents
  4. User reads contents
  5. User clicks the close button to close the DIV (the div is "closed" by using the removeChild() function)

Everything is peachy in Firefox, but if I try to open another message starting at step 1, Safari ruins my day by giving me "DOM Exception 8" and steps 2-5 don't happen.

I think this bug is exclusive to Safari because it seemed like everything on google involving DOM Exception 8 was Safari related...I don't even know what DOM EXception 8 IS!

Any ideas how I can get around this? I haven't even bother trying IE yet 🙁

Thanks
Steve

    This may sound strange but how about create a blank div locate it off the screen and/or set it's display to "none". Then just use document.getElementById(id).innerHTML = "your content here" to place the content you wish in the div and at the same time reposition the div were you need it.

      That's actually how I did it originally but I can foresee some instances in the future where it might be handy to have a generic way of adding this functionality in a more dynamic way.

      Anyways, it looks like I fixed the problem somehow (still not sure what I did), but when/if I ever figure out how to avoid a DOM Exception 8 I'l be sure to post it here.

      Thanks
      Steve

        slindstr wrote:

        That's actually how I did it originally but I can foresee some instances in the future where it might be handy to have a generic way of adding this functionality in a more dynamic way.

        You can put variables in the "innerHTML" content, or you can run it in a function or have different/multiple ones trigger based on different events. I don't think you can get much more dynamic than that.

          8 days later
          function floatDiv(http_request){
              	if(http_request.readyState == 4){
              		if(http_request.status == 200){
          
          			findScreenCenter();
          
          		var brotherNode = document.getElementById('wrapper');
          		var bodyHandle = document.getElementById('body');
          
          		floatingDiv = document.createElement('div');
          		floatingDiv.setAttribute('id', 'mail_reader');
          		floatingDiv.innerHTML = http_request.responseText;
          		floatingDiv.style.position = 'absolute';
          		floatingDiv.style.left = screen_center_x+'px';
          		floatingDiv.style.top  = screen_center_y+'px';
          
          		bodyHandle.insertBefore(floatingDiv, brotherNode);
          		}
          	}
          }
          

          I meant dynamic in the sense that I don't have to clutter my HTML with a random div that you can't see until it's activated. This way I just need to call a function and it creates the div for me.

            15 days later
            Write a Reply...