[Javascript] innerHTML problem
Cutter (JSRelated)
java.script at cutterscrossing.com
Mon Oct 9 14:23:07 CDT 2006
In my experience, the element must contain something before you are able
to replace it's contents with innerHTML. This may not be true for all
browsers, but I have found that if I have at least a non-breaking space
( ) in the contents of the div to begin with then I generally never
have an issue in any browser on any platform. Anyone else seen similar?
Cutter
____________________
http://blog.cutterscrossing.com
pedro mpa wrote:
> Hi!
>
> I'm trying to change the innerHTML of a div for a date time picker using
> javascript.
>
> [...]
> <div id="datetimepicker"></div>
>
> <script id="dyn_js_element" src="" language="javascript"
> type="text/javascript"></script>
>
> <script language="javascript" type="text/javascript">
> function DynamicScriptSrc(script_src_url) {
> document.getElementById("dyn_js_element").src=script_src_url;
> //(1) alert();
> }
>
> // first call:
> DynamicScriptSrc('datetimepicker.61009.php');
> </script>
> [...]
>
> // The php script returns js code for dyn_js_element (exmaple):
> document.getElementById('datetimepicker').innerHTML =
> '<?=str_replace("\t","", str_replace("\r\n","",$content))?>';
>
> The problem is the innerHTML of the div datetimepicker only gets updated if
> I add an alert(); (1) to the DynamicScriptSrc function, although it works on
> the first call. Why? Is there a workaround? :)
>
> Does an innerHTML cross-browser function/property exists?
>
> Apologies for my bad English.
>
> Thanks in advance.
> Pedro.
More information about the Javascript
mailing list