Re: executing javascript set with innerHTML in IE 7



On Jul 14, 2:21 pm, Thomas 'PointedEars' Lahn <PointedE...@xxxxxx>
wrote:
You are welcome.  Please also take heed of the recommendations about proper
quoting.

I love usenet!


This is not a code factory; you should read postings more thoroughly:

I used `_global' in the code and `global' in the explanation, but you should
get the picture anyway.


It's not a matter of not reading thoroughly, I will admit that after
over 10 years of exposure to the DOM, it and its functions, elements,
scopes, references, and after you add the cross-browser
inconsistencies - still leaves me confused. It's my comprehension that
is lacking.


Sorry, I forgot to consider a peculiarity of MSHTML that requires you to set
the `type' property of the object before you insert it in the DOM tree.
Therefore, this should work (tested positive in IE 7.0.5730.11):

  var input = document.createElement("input");
  if (input)
  {
    input.type = "button";
    element.appendChild(input);
    input.value = "test me";
  }

This did actually work for both IE and Firefox, however...

Setting up the function and appending it to the input won't work for
my real-case scenario. Popping up a window is not what I'm really
trying to achieve. The script is already set in the html that I'm
returning from an Ajax call and it needs to run inside the div that I
insert it to. I didn't write any of this btw, I wouldn't have used
Ajax.

So I'll ask again if anyone else knows - is there any way to have
javascript execute if it's dynamically written to a div? For example,
html, with a script in it, returned from an Ajax response, inserted
into a div.

.



Relevant Pages

  • Re: some validation errors f
    ... an html element and a head element to be "opened". ... The validator will flag an error. ... have a div here, as you have been told a few times before. ... able to use ajax to repace the "content" of that div, ...
    (comp.infosystems.www.authoring.html)
  • Re: How to detect and fix oversize Ajax load to innerHTML
    ... I have an popup DIV that loads arbitrary web content through use of ... Here is a much trimmed version of the HTML: ... Here is a much trimmed version of the Ajax success code: ...   bodyObj.html; ...
    (comp.lang.javascript)
  • Re: innerHTML with AJAX problem
    ... In a page I insert some HTML with a DIV by AJAX. ... var ajaxRequest; // The variable that makes Ajax possible! ...
    (comp.lang.javascript)
  • Re: innerHTML with AJAX problem
    ... In a page I insert some HTML with a DIV by AJAX. ... var ajaxRequest; // The variable that makes Ajax possible! ...
    (comp.lang.javascript)
  • Re: innerHTML with AJAX problem
    ... In a page I insert some HTML with a DIV by AJAX. ...   ajaxSimpleText; ...
    (comp.lang.javascript)