Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Resizing font size on pageload

Resizing font size on pageload

Scheduled Pinned Locked Moved Web Development
helpquestioncollaborationtoolstutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheIdleProgrammer
    wrote on last edited by
    #1

    Hi everyone, Please forgive me if this seems like a dumb question. I'm not very familiar with web development so whilst I go trawling the web for answers I thought I put up a quick post to see if anyone out there could help... Since a member of our team left I've been asked to look at a problem with our Internet Explorer based windows app and I'm not really too sure a) exactly what the problem is and b) how to fix it. When our app is minimised and an event causes the page to reload the text shrinks so that when the page is restored the text is unreadable. As soon as the page is reloaded the normal text size is restored. In the template for all pages is some script that is called from the body tags' onresize event handler that I think applies: function SetTextSize() { document.styleSheets[0].rules[0].style.fontSize = document.body.offsetWidth/40; } I believe this is a way of dynamically resizing the text depending upon the width of the window, however it is though the width of the window becomes very small when minimised, hence the text shrinking. Does anybody know if this is a stadard thing to do? Is there a better way to do it that will maintain the dynamic resizing of text but not shrink the text when the page is minimised?

    C 1 Reply Last reply
    0
    • T TheIdleProgrammer

      Hi everyone, Please forgive me if this seems like a dumb question. I'm not very familiar with web development so whilst I go trawling the web for answers I thought I put up a quick post to see if anyone out there could help... Since a member of our team left I've been asked to look at a problem with our Internet Explorer based windows app and I'm not really too sure a) exactly what the problem is and b) how to fix it. When our app is minimised and an event causes the page to reload the text shrinks so that when the page is restored the text is unreadable. As soon as the page is reloaded the normal text size is restored. In the template for all pages is some script that is called from the body tags' onresize event handler that I think applies: function SetTextSize() { document.styleSheets[0].rules[0].style.fontSize = document.body.offsetWidth/40; } I believe this is a way of dynamically resizing the text depending upon the width of the window, however it is though the width of the window becomes very small when minimised, hence the text shrinking. Does anybody know if this is a stadard thing to do? Is there a better way to do it that will maintain the dynamic resizing of text but not shrink the text when the page is minimised?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I've never seen anyone do anything like that before. I'd ditch it. Seems like an obvious way to solve the problem. Or even just have code so it doesn't go below a certain base level.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      T 1 Reply Last reply
      0
      • C Christian Graus

        I've never seen anyone do anything like that before. I'd ditch it. Seems like an obvious way to solve the problem. Or even just have code so it doesn't go below a certain base level.

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        T Offline
        T Offline
        TheIdleProgrammer
        wrote on last edited by
        #3

        Having looked around the web I've seen a couple of examples where it's done. I've looked a little closer at my template and realised why it won't work. There is a body tag 'onresize' event handler that calls the SetTextSize function but that isn't working, presumably because it's not valid html anymore. This should overcome the small font problem because the resize event will be fired when the page is maximised (I think) and so reset the font size. I think a new valid implementation of the resize event should be implemented in the form of: window.onresize = function; I have tried this and it won't work for me either. Any guesses? I've included the code for reference. None function LoadActions() { SetTextSize(); window.navigate('event?IP=PAGELOAD'); } function SetTextSize() { document.styleSheets[0].rules[0].style.fontSize = document.body.offsetWidth/40; } window.onresize = SetTextSize; $$BODY_CONTENT$$

        J 1 Reply Last reply
        0
        • T TheIdleProgrammer

          Having looked around the web I've seen a couple of examples where it's done. I've looked a little closer at my template and realised why it won't work. There is a body tag 'onresize' event handler that calls the SetTextSize function but that isn't working, presumably because it's not valid html anymore. This should overcome the small font problem because the resize event will be fired when the page is maximised (I think) and so reset the font size. I think a new valid implementation of the resize event should be implemented in the form of: window.onresize = function; I have tried this and it won't work for me either. Any guesses? I've included the code for reference. None function LoadActions() { SetTextSize(); window.navigate('event?IP=PAGELOAD'); } function SetTextSize() { document.styleSheets[0].rules[0].style.fontSize = document.body.offsetWidth/40; } window.onresize = SetTextSize; $$BODY_CONTENT$$

          J Offline
          J Offline
          Johnny
          wrote on last edited by
          #4

          Christian's suggestion was good - ditch the technique. I'd be very annoyed with a website if it started changing the size of fonts when I resized the browser, and would more than likely never use it again. Also, I'm not sure if you're aware, but the onload attribute is spelled önload (note the umlaut)

          T 1 Reply Last reply
          0
          • J Johnny

            Christian's suggestion was good - ditch the technique. I'd be very annoyed with a website if it started changing the size of fonts when I resized the browser, and would more than likely never use it again. Also, I'm not sure if you're aware, but the onload attribute is spelled önload (note the umlaut)

            T Offline
            T Offline
            TheIdleProgrammer
            wrote on last edited by
            #5

            Ok guys, thanks very much for your help. I've taken your advice and I'm going for a font defined by the fixed screen width. Cheers, Chris.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups