IE not accepting rewritten Javascript

G

garey

Hi -

I am trying to work with a large scale app that uses tokens to
drop script tags and Javascript into a page. Basically, I have to add
a line or two to the Javascript.

Several different strategies have worked for Firefox, but none of
them for IE. I tried grabbing the innerHTML of the div the script tag
is in and reforming it to include my code and then reassigning it to
the divs innerHTML, but that didn't work. Now I'm trying to create a
new div, assign to it's innerHTML and then do a replaceChild().

This works in Firefox. It works in IE in so far as I can view
source and see that the Javascript is being rewritten, but the
rewritten Javascript is not being executed. It appears that the
original Javascript is being executed. How can I get IE to execute the
new Javascript?
 
J

JR

I am trying to work with a large scale app that uses tokens to
drop script tags and Javascript into a page. Basically, I have to add
a line or two to the Javascript.
[...] This works in Firefox. It works in IE in so far as I can view
source and see that the Javascript is being rewritten, but the
rewritten Javascript is not being executed. It appears that the
original Javascript is being executed. How can I get IE to execute the
new Javascript?

Maybe writing the client-side script via a server-side 'language' such
as PHP should do the trick. In other words, you might send the params
(tokens?) to a PHP page, using GET or POST for instance, and return a
new page with new scripts to the user's browser.
Several different strategies have worked for Firefox, but none of
them for IE. I tried grabbing the innerHTML of the div the script tag
is in and reforming it to include my code and then reassigning it to
the divs innerHTML, but that didn't work. Now I'm trying to create a
new div, assign to it's innerHTML and then do a replaceChild().

Why do you need to place scripts in a div? Write script tags directly
in the body.

Cheers,
JR
 
D

David Mark

Hi -

     I am trying to work with a large scale app that uses tokens to
drop script tags and Javascript into a page. Basically, I have to add
a line or two to the Javascript.

     Several different strategies have worked for Firefox, but noneof
them for IE.

So you are feeling your way along? That's not a good strategy for
browser scripting (particularly a large scale app).
I tried grabbing the innerHTML of the div the script tag
is in and reforming it to include my code and then reassigning it to
the divs innerHTML, but that didn't work.

If appeared to work would you use it? There's certainly no basis to
believe that it would work in a random browser.
Now I'm trying to create a
new div, assign to it's innerHTML and then do a replaceChild().

     This works in Firefox. It works in IE in so far as I can view
source and see that the Javascript is being rewritten, but the
rewritten Javascript is not being executed.

If it had appeared to work, would you trust that it works outside of
whatever FF and IE versions/configurations that you tested?
It appears that the
original Javascript is being executed. How can I get IE to execute the
new Javascript?

I really can't imagine what you are trying to do exactly. I think you
are off in the weeds without a compass. But if you can explain more
clearly, perhaps there is a solution (and it is definitely not among
those presented so far).
 
G

garey

David -

Perhaps I didn't explain myself clearly enough for you. I
have a large application whose code is black box for me. I do
have access to the HTML for the web pages though. In the web pages,
they use tokens as macros for bits of Javascript and HTML that they
drop into the page when it is sent to the browser.

One of these tokens results in a Javascript function that does
not do all that I need it to do. Specifically, I have added several
selects whose selected options I want to merge into one of the selects
that the page provides before the form action is performed. I cannot
modify the code directly, because I do not have control over what the
token resolves to.

So my solution is to rewrite the Javascript produced by the token
whenever an option from one of my selects is selected.

My first attempt was to grab the contents of the <script> tag by
finding the parent (the parent has a distinctive class name) and
looping through
its nodes looking for a script node. But this didn't work. All the
nodes
came back as 'text' nodes. I'm sure I could figure that out, but I
thought
I had another way in. I grabbed the content of the parent as
innerHTML, spliced
in the code that I needed, and then reassigned it to the innerHTML.
This worked
in Firefox but not in IE, since I couldn't seem to change the actual
content
of the tag. My next attempt was to create a new node to replace
the parent div, assign the rewritten innerHTML to it, and do a
replaceChild on
the parent of the parent div.

Does this make sense so far? It works in Firefox. It works in
Crome. It
partially works in IE, since, once the function that does this is run,
I can
view the source code and see that my changes are there. Unfortunately,
when
the Javascript I rewrote is run, the unmodified code is run, not the
modified
code. I am just looking for a way to get IE to see the new code.

Garey Mills
 
T

Thomas 'PointedEars' Lahn

Thomas said:
garey said:
Perhaps I didn't explain myself clearly enough for you. [...]

Or for any other third person, and it hasn't gotten considerably better.

<http://jibbering.com/faq/#posting> pp.
<http://www.catb.org/~esr/faqs/smart-questions.html>

To be more verbose:

<http://www.catb.org/~esr/faqs/smart-questions.html#volume>
<http://www.catb.org/~esr/faqs/smart-questions.html#goal>

As for the latter, the "question" you are "asking" is indicative of trying
to cure the symptoms of a wrong approach:


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top