Giter Site home page Giter Site logo

Comments (9)

4nduril avatar 4nduril commented on June 6, 2024

You can load it by opening a url with fragment identifier. I.e. somesite.com/#modal1 for example.

from css-modal.

ScotsScripts avatar ScotsScripts commented on June 6, 2024

That makes sense. I was thinking more along the lines of arbitrarily opening it up on a page load regardless of which link they click on. For example, have the modal open on the 4th page load by a site visitor. Is there a way to set that #modal1 fragment identifie using javascript when the page loads? Thanks for the help, I appreciate it.

from css-modal.

4nduril avatar 4nduril commented on June 6, 2024

You could do something like location.hash = "modal1";. Wrap it in any (callback) function you want to.

from css-modal.

ScotsScripts avatar ScotsScripts commented on June 6, 2024

I was able to figure out how to make it work with your suggestion. This is going to help with something I'm working on, really appreciate the tip, thanks!

from css-modal.

ScotsScripts avatar ScotsScripts commented on June 6, 2024

I just ran into an issue with this. In firefox when I change the hash, the modal doesn't automatically pop up. The other browsers work as expected. Perhaps I'm not doing it right. In the head I have this (sm is the id of the modal):

<script type="text/javascript">window.location.hash = "sm";</script> </script> <script src="js/modal.js"></script>

It's a very simple setup but even though #sm is being added to the URL, the modal doesn't automatically pop up. It will come up if I reload the URL with the #sm on it. Any ideas?

from css-modal.

ScotsScripts avatar ScotsScripts commented on June 6, 2024

Head example didn't come through, I'll try indenting it.

<script type="text/javascript">window.location.hash = "sm";</script>
<link rel="stylesheet" href="css/modal.css"></script>
<script src="js/modal.js"></script>

from css-modal.

anselmh avatar anselmh commented on June 6, 2024

Thanks for the additional details. As I am able to confirm this, I now reopen the issue. A bugfix is coming soon! For the time being you can fix this by extending the :target selectors by:

&:target,
&.is-active {
    …
}

As the .is-active class is set by the js this will then trigger your modal on load.

from css-modal.

ScotsScripts avatar ScotsScripts commented on June 6, 2024

That worked! I went into the css file and found every instance of :target and basic went from this:

.semantic-content:target {
display: block\9;
 }

to this:

.semantic-content:target, .semantic-content.is-active {
display: block\9;
 }

Thanks a lot for the help, it's very much appreciated.

from css-modal.

drublic avatar drublic commented on June 6, 2024

The fix landed. Thanks :)

from css-modal.

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.