469,294 Members | 1,742 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,294 developers. It's quick & easy.

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 1256
Dormilich
8,651 Expert Mod 8TB
using document.write() is a very outdated way to add content. to give advice Id like to know, what you want to do there, currently I see no reason to use Javascript at all.

btw, you didnt 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.

Similar topics

1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.