By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,625 Members | 1,636 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,625 IT Pros & Developers. It's quick & easy.

javascript in div

P: 2
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. ....
  15. <script ...
  17. function showSpecial()
  18. {
  19. document.write("Today's Special is " + specials);
  20. }
  22. -->
  23. </script>
  24. ..........
  25. <body ...
  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
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 8,639
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

P: 2
you can see the full code at 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.