SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using javascript to generate dynamic content with CSS

    when generating the dynamic page with javascript, i also add a link to the stylesheet. However if I reload that dynamically generated page , it loses all its color and font properties.

    Why does this happen?


    also suppose I have two frames and on the left frame is a button which calls a function to write dynamic content to the right frame. After writing the dynamic content to the right frame. I click on the "reload" button in the browser. The dynamic page loses all its css formatting and more importantly the button which calls the javascript function no longer works properly! What I am trying to say is that if I click on the button right after reloading the page it doesnt work. But if I close and reopen the browser and then clicked on the button it will call the function and dynamic content is written to the right frame.

    How come the button (which calls the function) doesnt work if I reload the page? By the way I am using Mozilla

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    of course your dynamic styles will disapear after a reload. Think about it ... what happens when you reload a page? You get the first load, reinitialized page with all of the javascript and CSS reinitialized JUST LIKE if you had loaded the page for the first time..

    If you want dynamic things to stay around after reload your going to have to start looking into cookies (or sessions) to store the data so YOU can reload the page properly AFTER checking what styles were in place before the reload.

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why does this happen?
    Reloading a page is just like loading it for the first time. A web page is said to be 'stateless' meaning it has no memory. When you reload your page, the page has no memory of what you did to it with your js.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •