Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Refresh the page once detect resolution changes

    Hi,

    I was wanna to have a script that can make a refresh to the page once it detect change in resolution.
    I mean script make detect for resolution every second, and once changed , it make refresh itself...
    By posting in DevShed, a gr8 member replied with a script he made as follows:

    code:----------------------------------------------------------
    <script type="text/javascript"><!-- webmasta

    var br =(navigator.appName =='Netscape')? 0 : 1;
    var olRes =(br)? screen.availWidth : screen.width;

    function chekRes() {
    var chRes =(br)? screen.availWidth : screen.width;
    if (olRes != chRes) { location =location; }
    }
    //--></script>

    <body onload="setInterval('chekRes()', 1000);">
    --------------------------------------------------------------
    But it still not workin

    Hope I could find a solution for that soon

    Thanks

    Shady

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not really sure what you are asking,
    or what exactly doesn't work in your script.

    But, the reloadIt() function I added should
    reload the page once if your arguements are valid.

    <script type="text/javascript">
    <!--
    function reloadIt() {
    isNew = self.location.href
    if(!isNew.match('#')) {
    self.location.replace(isNew + '#')
    }
    }

    var br =(navigator.appName =='Netscape')? 0 : 1;
    var olRes =(br)? screen.availWidth : screen.width;

    function chekRes() {
    var chRes =(br)? screen.availWidth : screen.width;
    if (olRes != chRes){
    reloadIt();
    }
    }

    //-->
    </script>

    ....Willy

  • #3
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    RE:

    Thanks

    I tried it also but no way, about the problem:

    check www.ifcalex.com/xetronix

    I made a text layer that work with swap image in the main page, this work good in all resolutions
    But when you open the page and change the resolution without close the page, the text layer position not refreshed.
    So I was lookin for kind of script that can detect the change of resolution so it make a auto refresh 2 solve the issue.
    Hope we can work around it 2 make it happen
    Thanks again

    Shady

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    the browser has to remember the old resolution...
    Code:
    var br =(navigator.appName =='Netscape')? 0 : 1;
    var olRes = (br) ? screen.availWidth : screen.width;
    var savedOlRes;
    if (top.name) 
      savedOlRes = top.name;
    else {
      savedOlRes = olRes;
      top.name = olRes;
    }
    
    function chekRes() {
      var chRes = (br) ? screen.availWidth : screen.width;
      if (savedOlRes != chRes) location.reload();
    }
    
    <body onload="setInterval('chekRes()',1000)">
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for join us...
    I tried your code, still page don't refresh when resolution changed!!!
    Check updated code at www.ifcalex.com/xetronix


    Shady

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts

    It reloads, but in endless loop...

    I forgot to update the remembered screen width, that's why when you change the resolution, the page will reload endlessly.

    Code:
    var olRes = screen.width;
    var savedOlRes;
    if (top.name) 
      savedOlRes = top.name;
    else {
      savedOlRes = olRes;
      top.name = olRes;
    }
    
    function chekRes() {
      var chRes = screen.width;
      if (savedOlRes != chRes) {
        top.name = chRes; 
        location.reload();
      }
    }
    You can just use screen.width.
    Last edited by glenngv; 10-11-2003 at 02:33 PM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    RE:

    I tried it on www.ifcalex.com/xetronix

    I was on 1024 res then changed to 800 and it refreshed, but there is two issue:

    1- When the page refreshed, it keep refresh every second, while the res 800 didn't changed, so we wanna make it stop and only detect check till the resolution change again.

    2- Due to the first issue, when return back from 800 to 1024, refresh not workin.

    Thanks alot

  • #8
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    How many people change their resolution as they surf the web???? I doubt anyone does really unless they are really bored

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts

    Re: RE:

    Originally posted by shadyy
    I tried it on www.ifcalex.com/xetronix

    I was on 1024 res then changed to 800 and it refreshed, but there is two issue:

    1- When the page refreshed, it keep refresh every second, while the res 800 didn't changed, so we wanna make it stop and only detect check till the resolution change again.

    2- Due to the first issue, when return back from 800 to 1024, refresh not workin.

    Thanks alot
    I already fixed that in the 2nd code I posted. Did you try it?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #10
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes I tried , view source yourself

    The two issue remain till now, thnx 4 check

  • #11
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts

    Re: It reloads, but in endless loop...

    Originally posted by glenngv
    I forgot to update the remembered screen width, that's why when you change the resolution, the page will reload endlessly.

    Code:
    var olRes = screen.width;
    var savedOlRes;
    if (top.name) 
      savedOlRes = top.name;
    else {
      savedOlRes = olRes;
      top.name = olRes;
    }
    
    function chekRes() {
      var chRes = screen.width;
      if (savedOlRes != chRes) {
        top.name = chRes; 
        location.reload();
      }
    }
    You can just use screen.width.
    You didn't use the updated code I posted.
    Did you notice the added line (top.name = chRes) in the chekRes() funtion?
    I even said that you can just use screen.width.
    Is my 2nd post invisible?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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