Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Updating a div with a block of javascript and causing reexecution of this javascript block?

5 views
Skip to first unread message

mai...@gmail.com

unread,
Nov 2, 2006, 4:17:31 PM11/2/06
to
Hi,

I got the following situation using the AC_Quicktime library.
Apple recommend to use a Javascript call to generate the OBJECT tag
(http://developer.apple.com/internet/ieembedprep.html).

I am storing String entries representing the innerHTML of a div that I
will update at runtime.
As a result, some of these string entries are actually loooking like:
<script language="JavaScript" type="text/javascript">
QT_WriteOBJECT_XHTML('sample.mov', '320', '256', '',
'autoplay', 'true',
'emb#bgcolor', 'black',
'align', 'middle');
</script>
and not like that:
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
width="320" height="256"

codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0"
align="middle" >
<param name="src" value="sample.mov" />
<param name="autoplay" value="true" />
<embed src="sample.mov" width="320" height="256"
pluginspage=http://www.apple.com/quicktime/download/
align="middle" autoplay="true" bgcolor="black" > </embed>
</object>

Now my problem is that when I update tmy div via Javascript, I replace
the div.innerHTML by the string entry that I have retrieved.
Since in some cases these entries are Javascript blocks, I would want
them to execute but they are not when just replacing the innerHTML.
Obviously, because these are dynamic entries, I could not execute the
QT_ Javascript method call from my javascript function.

Is there any way to force reexecution of this block of javascript?

Thanks

Michael

Any idea?

draken

unread,
Nov 2, 2006, 4:59:21 PM11/2/06
to
Simply dynamically creating a 'wrapper' div, and replacing this wrapper,
with the current one and then writing the output of the javascript into the
new wrapper div should do the job. This essentially creates a 'reset'.

We had been doing some dynamically stuff with media and 2d/3d viewings and
this is the same structure we use.

-CJ

<mai...@gmail.com> wrote in message
news:1162502251.4...@k70g2000cwa.googlegroups.com...

VK

unread,
Nov 2, 2006, 5:56:26 PM11/2/06
to

mai...@gmail.com wrote:
> I got the following situation using the AC_Quicktime library.
> Apple recommend to use a Javascript call to generate the OBJECT tag

fn EOLAS issue I guess...
see
<http://groups.google.com/group/comp.lang.javascript/msg/dedadd8801c863d7>

also in this particular issue feel free to use document.write and any
other durty coding you want.

Randy Webb

unread,
Nov 2, 2006, 5:57:41 PM11/2/06
to
mai...@gmail.com said the following on 11/2/2006 4:17 PM:

> Hi,
>
> I got the following situation using the AC_Quicktime library.
> Apple recommend to use a Javascript call to generate the OBJECT tag
> (http://developer.apple.com/internet/ieembedprep.html).

Yes, and it is the same "solution" provided by MS as a result of the
EOLAS suit.

<snip>

> Now my problem is that when I update tmy div via Javascript, I replace
> the div.innerHTML by the string entry that I have retrieved.
> Since in some cases these entries are Javascript blocks, I would want
> them to execute but they are not when just replacing the innerHTML.
> Obviously, because these are dynamic entries, I could not execute the
> QT_ Javascript method call from my javascript function.

Create a new script block and create the script element on the fly.
Search the archives for a function name of createJSFile() and you can
find many threads where it is explained.

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

Michael

unread,
Nov 3, 2006, 6:21:39 PM11/3/06
to
That will work nicely on Firefox but not on Safari

Randy Webb

unread,
Nov 3, 2006, 6:51:35 PM11/3/06
to
Michael said the following on 11/3/2006 6:21 PM:

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?

> That will work nicely on Firefox but not on Safari

Does Safari support createElement, appendChild and setting the .src or
.text property of that script element?

<script type="text/javascript">
function loadJSFile(){
var newScript = document.createElement('script');
newScript.type = "text/javascript";
newScript.text = "alert('It Worked');
document.getElementById('scriptDiv').appendChild(newScript);
}

window.onload = loadJSFile;
</script>
<div id="scriptDiv"></div>

When running that in Safari, do you get the alert, an error message, or
nothing?

mick white

unread,
Nov 3, 2006, 8:09:20 PM11/3/06
to
Randy Webb wrote:

> Michael said the following on 11/3/2006 6:21 PM:
>
> Answer:It destroys the order of the conversation
> Question: Why?
> Answer: Top-Posting.
> Question: Whats the most annoying thing on Usenet?
>
>> That will work nicely on Firefox but not on Safari
>
>
> Does Safari support createElement, appendChild and setting the .src or
> .text property of that script element?
>
> <script type="text/javascript">
> function loadJSFile(){
> var newScript = document.createElement('script');
> newScript.type = "text/javascript";
> newScript.text = "alert('It Worked');
> document.getElementById('scriptDiv').appendChild(newScript);
> }
>
> window.onload = loadJSFile;
> </script>
> <div id="scriptDiv"></div>
>
> When running that in Safari, do you get the alert, an error message, or
> nothing?
>

newScript.text = "alert('It Worked');// missing closing quote mark.


newScript.text = "alert('It Worked')";

In Safari, nothing, no error, nothing.
Mick

Randy Webb

unread,
Nov 3, 2006, 9:40:46 PM11/3/06
to
mick white said the following on 11/3/2006 8:09 PM:

I remember that quote mark and obviously missed fixing it before posting :-\

> In Safari, nothing, no error, nothing.

What about this code:

<script type="text/javascript">
function loadJSFile(){
var newScript = document.createElement('script');
newScript.type = "text/javascript";

newScript.src = 'someFile.js';
document.getElementById('scriptDiv').appendChild(newScript);
}

window.onload = loadJSFile;
</script>
<div id="scriptDiv"></div>

Where someFile.js is an external file (you will have to create it) with
an alert('It worked') in it?

Also, since you have Safari, can you test this page:

<URL: http://members.aol.com/_ht_a/hikksnotathome/loadJSFile/index.html>

I don't have Safari listed there so if you could test it for me, I would
be grateful. What you should get is an initial alert when the page loads
that says "Initial File Loaded". Then there are three buttons across the
page. What happens when you click each? Also, what version of Safari and
what MAC OS you are using would be appreciated.

Anybody else that can test it and let me know OS, ver/rev browser and
what the results are so I can update it.

I may have to revisit it and change it to test for altering the script
elements .text property.

mick white

unread,
Nov 4, 2006, 8:26:39 AM11/4/06
to
Randy Webb wrote:

This works.

>
> Also, since you have Safari, can you test this page:
>
> <URL: http://members.aol.com/_ht_a/hikksnotathome/loadJSFile/index.html>

>
> I don't have Safari listed there so if you could test it for me, I would
> be grateful. What you should get is an initial alert when the page loads
> that says "Initial File Loaded".

This works.

Then there are three buttons across the
> page. What happens when you click each?

Create element // alerts "createElement worked"
Change innerHTML and Change Source // Nothing, no errors

Also, what version of Safari and
> what MAC OS you are using would be appreciated.


Mac OS 10.3.9, Safari 1.3.2 (v312.6)

Mick

VK

unread,
Nov 4, 2006, 12:10:14 PM11/4/06
to
> Mac OS 10.3.9, Safari 1.3.2 (v312.6)

Anything below Safari 2.0 is irrelevant for the web-development.

It is not a bias: just the plain technical true. Just to give you a
touch of how low initially was it: 1.1. (not some 0.1) was hanging up
on any attempt to use JavaScript.

P.S. Do you still want another better world, man? Go get it in 3D,
we'll try to help ye...

mick white

unread,
Nov 4, 2006, 2:48:58 PM11/4/06
to
VK wrote:

>> Mac OS 10.3.9, Safari 1.3.2 (v312.6)
>
>
> Anything below Safari 2.0 is irrelevant for the web-development.
>

What a stupid statement.
Mick

Randy Webb

unread,
Nov 4, 2006, 4:08:47 PM11/4/06
to
mick white said the following on 11/4/2006 8:26 AM:
> Randy Webb wrote:

<snip>

> Then there are three buttons across the
>> page. What happens when you click each?
> Create element // alerts "createElement worked"
> Change innerHTML and Change Source // Nothing, no errors
>
> Also, what version of Safari and
>> what MAC OS you are using would be appreciated.
>
>
> Mac OS 10.3.9, Safari 1.3.2 (v312.6)

Thank you, I have it updated locally and will update it online sometime
tonight.

Randy Webb

unread,
Nov 4, 2006, 4:09:31 PM11/4/06
to
mick white said the following on 11/4/2006 2:48 PM:

Mick, meet VK :) 99.99% of what he says falls into that category.

Michael

unread,
Nov 4, 2006, 10:06:51 PM11/4/06
to

on Mac OS 10.4 with Safari 2.0.4, when I hit
http://members.aol.com/_ht_a/hikksnotathome/loadJSFile/index.html, I
get the following:

CreateElement : I get the alert
Change Source or innerHTML : nothing, no error, no alert

Hope that helps

Michael

On Nov 4, 1:09 pm, Randy Webb <HikksNotAtH...@aol.com> wrote:
> mick white said the following on 11/4/2006 2:48 PM:
>
> > VK wrote:
>
> >>> Mac OS 10.3.9, Safari 1.3.2 (v312.6)
>
> >> Anything below Safari 2.0 is irrelevant for the web-development.
>

> > What a stupid statement.Mick, meet VK :) 99.99% of what he says falls into that category.

Randy Webb

unread,
Nov 4, 2006, 10:43:47 PM11/4/06
to
Michael said the following on 11/4/2006 10:06 PM:

>
> on Mac OS 10.4 with Safari 2.0.4, when I hit
> http://members.aol.com/_ht_a/hikksnotathome/loadJSFile/index.html, I
> get the following:
>
> CreateElement : I get the alert
> Change Source or innerHTML : nothing, no error, no alert
>
> Hope that helps

It did. Do you happen to have a browser that isn't listed on that page?
The more comprehensive that I can make that list the better.


--
Randy
Chance Favors The Prepared Mind

0 new messages