Giter VIP home page Giter VIP logo

Comments (4)

Munter avatar Munter commented on May 25, 2024

This should be a bit easier now that I have fixed #17
We could just have the id in the fragment identifier and search for it when ready.

from charcod.es.

msiebuhr avatar msiebuhr commented on May 25, 2024

So. I've played with variations over the following

window.onpopstate = function (e) {
    // Shamelessly stolen from MDN
    function loadPageVar (sVar) {
        return unescape(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + escape(sVar).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
    }

    var query = loadPageVar("q");
    query = query.replace(/\/$/, ""); // Remove trailing slash

    searchAndShow(query);
    $("#searchField").val(query);
};

It decodes stuff on the form http://charcod.es/?q=QUERY/ and enters in the query-field - which is implicitly searched for when the data is done loading.

But. I can't get FF to fire window.onpopstate when it's loading the page, no matter where I put it. Chrome does it reliably.

My working hypothesis is that I'm hooking in the wrong place, but with my limited knowledge of browser internals, I probably missed something important somewhere else...

from charcod.es.

msiebuhr avatar msiebuhr commented on May 25, 2024

Ah. Re-reading the MDN-article on window.onpopstate, yields the following:

Browsers tend to handle the popstate event differently on page load. Chrome and Safari always emit a popstate event on page load, but Firefox doesn't.

from charcod.es.

msiebuhr avatar msiebuhr commented on May 25, 2024

Commited draft patch in d6b63d3 (yes, yes - experimental stuff should go in a branch...)

from charcod.es.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.