471,895 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,895 software developers and data experts.

javascript in div

I'm trying to get a simple simple simple function to execute inside a div tag and i can't get the div tag to do what it normally should do... i've searched the web for answers with no luck... here is the relevent code:
Expand|Select|Wrap|Line Numbers
  1. <style ...
  2. div.spec
  3. {
  4.     border: none;
  5.     position:absolute;
  6.     top: 300px;
  7.     left: 75px;
  8.     width:492px;
  9.     height:auto;
  10.     text-align: center;
  11. )
  12. </style>
  13. ....
  14.  
  15. <script ...
  16.  
  17. function showSpecial()
  18. {
  19. document.write("Today's Special is " + specials);
  20. }
  21.  
  22. -->
  23. </script>
  24. ..........
  25. <body ...
  26.  
  27. <div class="spec">
  28. <script type="text/javascript">
  29. <!--
  30. showSpecial();
  31. -->
  32. </script>
  33. </div>
the div shows the text... but it doesn't go where it should go... it just hangs at the top of the page... my other code free divs work fine though

please help
Sep 20 '09 #1
2 1293
Dormilich
8,658 Expert Mod 8TB
using document.write() is a very outdated way to add content. to give advice Iíd like to know, what you want to do there, currently I see no reason to use Javascript at all.

btw, you didnít define what the variable special is.
Sep 20 '09 #2
you can see the full code at lildaddysdowntown.com basically the script is to have the different specials show on different days........ specials is defined, i just didn't include the code above

if u look at the site, you can see the text is showing up behind the logo, not where it should be

EDIT: I found the problem and feel like an idiot i put a ) vs } by accident, but I'd still like to know some advice on a better way than using document.write()
Sep 20 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.