Jump to content
Search Community

Issue with CSSRule Plugin (DOMException)

Shahriar test
Moderator Tag

Recommended Posts

Hello ,

I include local file <script src="js/CSSRulePlugin.min.js"></script> but still now it's not working. there are two error 

DOMException: CSSStyleSheet.cssRules getter: Not allowed to access cross-origin stylesheet

GSAP target undefined not found. https://greensock.com . I need to target span:after so i have  locally  included CSSRulePlugin. i also included locally gsap <script src="js/gsap.min.js"></script>

 

Screenshot-60.png

 

 

index.html

  • Like 1
Link to comment
Share on other sites

Hey Shahriar and welcome to the GreenSock forums.

 

1 hour ago, Shahriar said:

DOMException: CSSStyleSheet.cssRules getter: Not allowed to access cross-origin stylesheet

That's a browser-level restriction that's there for security reasons. You can't edit stylesheets that are loaded from other domains. I recommend hosting the CSS file on the same site that you have your script if you need to do that.

 

What I actually recommend though is editing the styles so that you no longer have to edit the pseudo-element's CSS. We recommend either animating CSS variables instead or, if you need IE support, then making the pseudo-element a real element and animating that like you would any other element with GSAP. More details can be found in the CSSRulePlugin docs

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
  • 11 months later...

I am getting this same error with the plugin file hosted next to (or even inside a <script>) the banner document. No idea what's triggering a CORS from a single file. There's no errors on my pen below when I reference a CDN, but the error occurs on my web server & locally. Are browsers getting stricter or is there something about using it locally I am missing?

See the Pen gOxRMEP by howeller (@howeller) on CodePen

Link to comment
Share on other sites

No idea as that would be a server issue. I would try another plugin and see if the problem persists. If it's just with the CSSRulePlugin, then the problem is probably related to it not being able to parse/update the rules, which some browsers might block for security. 

 

It would probably be better to use CSS variables instead of the CSSRulePlugin as it gives you more control and you can target elements individually.

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...