slight improvement to the history/FF prob

OK, I’ve done my research, I think I was imagining the past ability to remove items from the history. However, here’s a solution that decreases the chances of breaking the back button in the browser:

In the parent frame: (instead of what’s shown above)

<iframe src="http://path/to/iframe.html" width="100%" frameborder="0" marginheight="0" marginwidth="0" id="downloadframe" style="height:350px"></iframe>
<script type="text/javascript">
    function checkFragment() {
        h = document.location.href.indexOf('#h');
        l = document.location.href.length;
        if( h > 0) {
            u = document.location.href.substring(h+2,l);
            // u will be like 312 or 312-123456 and we only want the 312
            height = parseInt(u.split('-')[0]);
            setFrameHeight(height);
            clearInterval(frameint);
            // fix for browsers whose navigation gets confused by this script
            if(history.length > his)
                history.go(-1)
        }
    }

    function setFrameHeight(height)
    {
        var frame = document.getElementById("downloadframe");
        frame.height = height + 20; // there's a bit of scroll without the 20
    }
    // used for fixing the history in ff
    his = history.length
    // our interval
    var frameint = self.setInterval('checkFragment()', 500);
</script>

Again, feedback is welcome.

Reply

Please solve the math problem above and type in the result. e.g. for 1+1, type 2.
The content of this field is kept private and will not be shown publicly.
  • You can use Markdown syntax to format and style the text.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Back to top