Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5973857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:51:35+00:00 2026-05-22T20:51:35+00:00

I know there are methods of adding content to a web page like stated

  • 0

I know there are methods of adding content to a web page like stated here: http://nooshu.com/adding-content-using-css3

But.. I wonder if there is also a possibility to declare a js event in css on given selected nodes, like:

.myclass {
   declare-js-event: "onclick";
   declare-js-function: "alert('I've been clicked!')"
}

If (as I highly suppose) it is not possible, then are these features at least planned in some future css v4 or is it ruled out by design and css would never be able to do such things ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:51:36+00:00Added an answer on May 22, 2026 at 8:51 pm

    You can declare JavaScript expressions and functions in CSS using IE’s expression() function. Another way is to use the url() function.

    For example:

    // Expression()
    selector { width: expression((document.body.clientWidth > 1024)? "1200px" : "960px"); }
    
    // URL()
    selector { background: url("javascript: alert('XSS')"); }
    

    Expressions in IE{6,7} add some additional logic that are sometimes used to cover up for the in cross-compatibility for IE; however, using expression() at all isn’t recommended.

    As cx42net answered, CSS handles presentation whereas JavaScript handles behaviour of a page. Using JavaScript in CSS isn’t common and usually manifests itself as an XSS attack as demonstrated in the url() example above.

    It’s possible to use JavaScript is older browser versions but I think they’re slowly removing support for it as IE8+ no longer supports expression(). That said, I don’t recommend using JavaScript at all in CSS especially if you expect your website to be Forward Compatible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What methods are available to monitor the status of IFRAME page, I know there
First, I know there are methods off of the generic List<> class already in
Is there a way to know the number of test methods in a test
What methods to use a database from Clojure are there? I know from Clojure
I know there is a method like this : setTimeout(functionA();,1250); That can delay my
I'd like to know if there is an automated method to add e-mail settings
We're creating a page in Orchard CMS using the 'List' Content Type. We want
as far as I know there are three methods to submit an HTML form
I have a web page who's content width is about 900px, but the minimum
I know there is a method for a Python list to return the first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.