SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    total noob question

    I want to make a script that will refresh the page when someone clicks anywhere on the page, except for hyperlinks (which, we know what they do) but ONLY for IE7

    document.onclick=function(){
    var browserName=navigator.appName;
    var browserVer=parseInt(navigator.appVersion);
    if (browserName=="Microsoft Internet Explorer" && browserVer==7)
    history.go(0);
    }

    this doesnt work. My lack of understanding of js is probably to blame here. I think the problem with this script is that this function is not loaded on startup of the page? Total noob here. I dunno, any ideas?

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Best thing is to use conditional comments.
    HTML Code:
    <--![if IE 7]><script type="text/javascript" src="ie7refresh.js"></script><![endif]-->
    Then in ie7refresh.js:
    Code Javascript:
    window.attachEvent('onload', refresh);
    function refresh() {
      document.body.onclick = function() {
        if (window.event.target.nodeName == 'A') return;
        else window.location.reload(true);
      }
    }
    That will make it reload from the server each time. If reloading from the cache is OK, use window.location.reload() instead of the above with "true" as a parameter.


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
  •