By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,282 Members | 1,569 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,282 IT Pros & Developers. It's quick & easy.

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

P: n/a
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?

Nov 2 '06 #1
Share this Question
Share on Google+
14 Replies


P: n/a
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

<ma*****@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
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?

Nov 2 '06 #2

P: n/a
VK

ma*****@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.

Nov 2 '06 #3

P: n/a
ma*****@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/
Nov 2 '06 #4

P: n/a
That will work nicely on Firefox but not on Safari

draken wrote:
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

<ma*****@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
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?
Nov 3 '06 #5

P: n/a
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(n ewScript);
}

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

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

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

P: n/a
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(n ewScript);
}

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

Nov 4 '06 #7

P: n/a
mick white said the following on 11/3/2006 8:09 PM:
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')";
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(n ewScript);
}

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.

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

P: n/a
Randy Webb wrote:
mick white said the following on 11/3/2006 8:09 PM:
>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')";


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(n ewScript);
}

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?
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
Nov 4 '06 #9

P: n/a
VK
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...

Nov 4 '06 #10

P: n/a
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
Nov 4 '06 #11

P: n/a
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
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 4 '06 #12

P: n/a
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
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 4 '06 #13

P: n/a


on Mac OS 10.4 with Safari 2.0.4, when I hit
http://members.aol.com/_ht_a/hikksno...ile/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.comwrote:
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
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
Nov 5 '06 #14

P: n/a
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/hikksno...ile/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
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 5 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.