![]() |
|
#1
|
|||
|
|||
|
Hi all,
I have a situation where i have to dynamically produce javascript, so i can't use a static (.js) file, and would prefer not to bounce the request off a php script (for simplicity's sake). The following works in Mozilla but not in IE...any suggestions appreciated.... var rem_date_td_2_js = document.createElement("script"); rem_date_td_2_js.type = 'text/javascript'; rem_date_td_2_js.id = 'js_rem_date_' + new_section_counter; rem_date_td_2_js.text = "var cal_rem_date_" + new_section_counter + " = new CalendarPopup ();" Thanks, Dominic madison.com |
|
#2
|
|||
|
|||
|
At a glance it's probably the .text property that is throwing IE off.
Try actually inserting this new element into the document somewhere, too. -- Regards, Tim Scarfe <tim@developer-x.com> http://www.developer-x.com |
|
#3
|
|||
|
|||
|
[code:v8v04he5oo]rrm_date_td_2_js.appendChild(
document.createTextNode( "var cal_rem_date_" + new_section_counter + " = new CalendarPopup ();" ) ) ;[/code:v8v04he5oo] No idea if it works, though. |
|
#4
|
|||
|
|||
|
You seem to be creating this "dynamic script" from another script... so you are already running JavaScript. Simply do this:
[code:565fkr46ub]window["cal_rem_date_" + new_section_counter] = new CalendarPopup ();[/code:565fkr46ub] - [url="http://neo.dzygn.com/"]Mark[/url:565fkr46ub] |
|
#5
|
|||
|
|||
|
lol!
No Mark that's far too simple.. -- Regards, Tim Scarfe <tim@developer-x.com> http://www.developer-x.com |
|
#6
|
|||
|
|||
|
<blockquote id="quote"><span class="smalltext" id="quote">quote:<hr id="quote">[code:f04aj7sxbg]window["cal_rem_date_" + new_section_counter] = new CalendarPopup ();[/code:f04aj7sxbg]<hr id="quote"></blockquote id="quote"></span id="quote">Way to make everyone else look foolish (especially me, as I stared at the question pondering solutions).
If you want to be really fancy about it, you could do: [code:f04aj7sxbg]var cal_rem_date = []; call_rem_date[ call_rem_date.length ] = new CalendarPopup( );[/code:f04aj7sxbg] Then you could do things like: [code:f04aj7sxbg]for( var i = 0; i < call_rem_date.length; i ++ ) call_rem_date.method( );[/code:f04aj7sxbg] <font color="brown"><font face="Courier New">.Brian</font id="Courier New"> <font size="2">Email: kerrick[at]gmx[dot]net - AIM: Brian K Nickel - Yahoo: brian_nickel - Jabber: Kerrick[at]jabber[dot]org - MSN: kerrick[at]gmx[dot]net - ICQ: 118451560</font id="size2"> Quidquid latine dictum sit, altum viditur.</font id="brown"> [edit]Fixed error stated below.[/edit] |
|
#7
|
|||
|
|||
|
<blockquote id="quote"><span class="smalltext" id="quote">quote:<hr id="quote">
var cal_rem_date = []; call_rem_date[ call_rem_date.length ++ ] = new CalendarPopup( ); <hr id="quote"></blockquote id="quote"></span id="quote"> I'm pretty sure Brian didn't mean to put in the ++ there.. -- Regards, Tim Scarfe <tim@developer-x.com> http://www.developer-x.com |
|
#8
|
|||
|
|||
|
<blockquote id="quote"><span class="smalltext" id="quote">quote:<hr id="quote">I'm pretty sure Brian didn't mean to put in the ++ there..<hr id="quote"></blockquote id="quote"></span id="quote">
*sigh* Its been too long. <font color="brown"><font face="Courier New">.Brian</font id="Courier New"> <font size="2">Email: kerrick[at]gmx[dot]net - AIM: Brian K Nickel - Yahoo: brian_nickel - Jabber: Kerrick[at]jabber[dot]org - MSN: kerrick[at]gmx[dot]net - ICQ: 118451560</font id="size2"> Quidquid latine dictum sit, altum viditur.</font id="brown"> |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|