Re: IE , SCRIPT and innerHTML



On Jan 18, 3:21 am, Randy Webb <HikksNotAtH...@xxxxxxx> wrote:
_q_u_a_m_i_s's said the following on 1/17/2008 9:46 AM:

Hy,
Let`s suppose the following example:

<div id="parent">
<div id="child">
dfsfdg dsfg
</div>
<script type="text/javascript">
alert('a');
</script>
</div>

by using alert($('parent').innerHTML) in FF i can see the exact tags
as written.
When using the same alert in IE, i cannot see the contents of
<script></script>.. it shows me an empty tag.

Why does IE shows me an empty tag?

Because something in Prototype is screwing it up. Or, something else in
the way you are trying to alert it.

<button
onclick="alert(document.getElementById('parent').innerHTML)">Test</button>

In IE7 gives me the script block contents.

i need to see the contents of that tag, and have no ideea how.
Anyone know a solution to access the contents of the script tag in IE?

Stop using prototype and access it directly, you will get the script
block contents.

I am curious why you need the text though. I have an idea about why but
am curious before I go any further with it.

$('id') is shorthand to document.getElementById('id') for those who
never used prototype:)

<quote>
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300d...@xxxxxxxxxxxxxxxx>
</quote>

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/


Thanks for the answer, seems like i as wrong, it`s not the $()
function( or the getElementById)... it was cloneNode.. but i`ts still
not fixed:(
Let`s start with a little background:
I`m trying to make "cloneFactory" class in js. I need pretty often to
be able to add/delete rows in forms . these forms generally contain a
table, and i need to be able to duplicare different TR`s
Before trying to make this class i was using AJAX(to add the new row,
with new INPUT names and id`s) or weird js hacks, generally made
specific for that type of form row.

Now i want to make a "template" element, in this case a TR, which
contains element id`s and names in a specific form.
Example:
the template: <TR id="template_.index."><TD>[... inputs and texts...],/
TD></TR>

in js i do a
template=new CloneFactory('template_.index.',{'index':{start:5,
type:'int'}});
[....]
and then put a button in the page with onClick="template.clone()"

when creating the CloneFactory, it will remove the element from the
DOM, and keep it in memory (so it will not get submited by mistake).

the template.clone will call cloneNode, and parse the cloned element
from memory, and where it sees elements with tags in the form of
".tag." it will try to make the replace (For the above example, the
first call to clone will generate a <TR id="template_5"><TD>[...
inputs and texts...],/TD></TR> this tag will be automatically appended
to the DOM...
I need the script tags, so that i can create different field
validators for the inputs in that row

The problem with IE is that when calling cloneNode, it removes the
content of the <script> tags, and so the inputs will never get
validated.
It work perfectly in FF, but sucks in IE.

I belive i`ll have to change the node-parsing process to a simple
String.replace on the entire innerHtml of the original element... but
i`d prefer parsing each tag separatelly... String.replace can make
stupid replacements if used on a element wich actually contains a
textnode with the ".index." string in it (i`d like to avoid this if
its possible)
.



Relevant Pages

  • Re: [Full-Disclosure] !A stupid bug ...that works on mozilla, opera, IE!
    ... > mozilla saying that the alert function isn't finished with a) ... Although the STYLE and SCRIPT elements use CDATA for their data ... Thus, even with correct quotes, the JavaScript code will be ... in the browser window. ...
    (Full-Disclosure)
  • Re: Scope question... I think...
    ... the problem with javascript not being evaluated inside Shadowboxed HTML ... // Shadowbox destroys javascript, ... Strips anything outside <script> tags, including the tags themselves, ...
    (comp.lang.javascript)
  • Re: Javascript includes not recognised
    ... > I'll check out the DOM object to see how I can check the script loading - ... >> before an alert at the point at which you call the function. ... >> I have web pages that are made up of a number of javascript include ...
    (microsoft.public.inetserver.asp.general)
  • Re: Javascript includes not recognised
    ... > I'll check out the DOM object to see how I can check the script loading - ... >> before an alert at the point at which you call the function. ... >> I have web pages that are made up of a number of javascript include ...
    (microsoft.public.inetserver.iis)
  • Re: How to use Include Files
    ... need in 4 pages with Javascript. ...   Any way to include the reusable code. ... since the `script' element requires the `type' attribute. ... they are tags which along ...
    (comp.lang.javascript)