Code Monkey home page Code Monkey logo

Comments (5)

fieg avatar fieg commented on June 9, 2024

Some of the pagination libraries

Do you have any examples?

It sounds like something very specific and I'm not sure if I should bloat IAS to support every other lib out there, but if this is a common thing or used by large libs I can consider it.

from infinite-ajax-scroll.

kzhang-dsg avatar kzhang-dsg commented on June 9, 2024

Hi fieg,

You can check this example out: https://us.brinks.com/insights. See the next button at the bottom of the page when you go to the last page. The href of the next button becomes href="javascript:;" on the last page.

We dont need to do library-specific logic. Just need to do an additional check to make sure the next button URL is valid before requesting it.

I know there is no customer support for the paid customer but I did pay for the license. I think it will help others to have this feature.

from infinite-ajax-scroll.

fieg avatar fieg commented on June 9, 2024

Thank you for your reply!

I see you point and agree, which leads me to a few questions:

  • What is a valid url and what's not? And how can we validate that?
  • Should IAS do this check, or should it allow users to implement this check themselves, in the few cases where this is needed?
  • Should IAS perhaps execute javascript prefixed hrefs? Not sure if this is even possible tho.

If you have thoughts on these questions, please share.

from infinite-ajax-scroll.

kzhang-dsg avatar kzhang-dsg commented on June 9, 2024

We can check if the URL is a valid URL by using regex: https://stackoverflow.com/questions/1303872/trying-to-validate-url-using-javascript, or simply check if the URL starts with https?://

To get the absolute URL, we can use this: https://stackoverflow.com/questions/3943281/resolving-relative-urls-in-javascript

It turns out that the .href attribute of a A element (not .getAttribute('href'), but .href) returns the resolved (absolute) URL.
  1. For <a href="https://example.com/page1">, the .href will return https://example.com/page1;
  2. For <a href="/page1">, the .href will return https://example.com/page1;
  3. For <a href="javascript:;">, the .href will return javascript:;;
  4. For <a href="javascript:alert('111');">, the .href will return javascript:alert('111');;

Once we got the absolute URL, we can check if the URL is valid or not.

from infinite-ajax-scroll.

fieg avatar fieg commented on June 9, 2024

Thank you for your detailed reply 🙏 I will take it into consideration. If you are up for it, feel free to send in a PR with a code proposal.

from infinite-ajax-scroll.

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.