Forum Moderators: open

Message Too Old, No Replies

writing html file dynamically through java script

writing Htmlfile

         

abhayasingh

11:59 am on Jul 25, 2006 (gmt 0)

10+ Year Member



I want to append some containts in pre existing html file i tried with document.append but its not working.Please reply assp .
Thanks

supermoi

3:51 am on Jul 26, 2006 (gmt 0)

10+ Year Member



You might wanna google for "javascript DOM tutorial". Good luck!

kaled

1:15 pm on Jul 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I understand you correctly (not sure) try this...

<body>
........
........

<script type="text/javascript">
document.open(); // not needed by most browsers
document.write('<a href="\">Home<\/script>');
</script>
</body>
</html>

Notice that the '/' char of closing tags should be escaped using the '\' char.

Kaled.

adni18

5:30 pm on Jul 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Notice that the '/' char of closing tags should be escaped using the '\' char.

Really? Why?

kaled

12:07 am on Jul 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Escaping is only required if the js code is embedded within an html page. Some (older) browsers may otherwise treat </ as </script>.

Kaled.

Rambo Tribble

2:14 am on Jul 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Document.write() will not allow contents to be appended. For that you need either innerHTML (the easy way) or DOM node manipulation methods (the right way).

adni18

4:07 pm on Jul 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




document.write('<a href="\">Home<\/script>');

Shouldn't that be <\/a>?

kaled

8:16 pm on Jul 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes it should be <\/a> ...

brain-fade get's all of us eventually.

Kaled.