Would it be possible to have pjax regex replace window.location calls into PJAX calls if they are on the same host?
I have some sites that I don't control the raw code, just the CMS and header/footer, and realized that it is using window.location in some weird places.
Would it be possible to have pjax regex replace window.location calls into PJAX calls if they are on the same host?
I have some sites that I don't control the raw code, just the CMS and header/footer, and realized that it is using window.location in some weird places.
I had meant the Ajax call that Pjax makes when loading in a new page. That comes back as a string of content doesn’t it?
So if all references to window.location in that string were replaced, window.location would never end up in the dom.
I had meant the Ajax call that Pjax makes when loading in a new page. That comes back as a string of content doesn’t it?
So if all references to window.location in that string were replaced, window.location would never end up in the dom.
v0.2.6 will have a new pjax.handleResponse() method that you can use to do that.
If you want to try it now, you can install from Github. With NPM, that would be npm install --save moox/pjax@master.
Then you can do something like this:
pjax._handleResponse = pjax.handleResponse;
pjax.handleResponse = function(responseText, response, href) {
if (responseText.contains("window.location") {
// Fix the response here
}
pjax._handleResponse(responseText, response, href);
}
v0.2.6 will have a new `pjax.handleResponse()` method that you can use to do that.
If you want to try it now, you can install from Github. With NPM, that would be `npm install --save moox/pjax@master`.
Then you can do something like this:
```
pjax._handleResponse = pjax.handleResponse;
pjax.handleResponse = function(responseText, response, href) {
if (responseText.contains("window.location") {
// Fix the response here
}
pjax._handleResponse(responseText, response, href);
}
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Would it be possible to have pjax regex replace window.location calls into PJAX calls if they are on the same host?
I have some sites that I don't control the raw code, just the CMS and header/footer, and realized that it is using window.location in some weird places.
I played around with it for a while. Basically, you can't reassign
windoworwindow.location. So I don't think this will work.Would it be possible to regex replace the content that comes back from the Ajax request before it gets processed?
If I'm not mistaken, assigning
window.locationdoesn't make an AJAX request, it reloads the page completely.I had meant the Ajax call that Pjax makes when loading in a new page. That comes back as a string of content doesn’t it?
So if all references to window.location in that string were replaced, window.location would never end up in the dom.
v0.2.6 will have a new
pjax.handleResponse()method that you can use to do that.If you want to try it now, you can install from Github. With NPM, that would be
npm install --save moox/pjax@master.Then you can do something like this:
Great, thanks!