1

I want to run js inside CSS when the page loaded.
Is this possible?

html{
    width: expression(document.getElementById('BeneficiaryLabel').innerHTML = 'test');
}

this doesn't work.

Thanks

1
  • The expressions were supported only in IE up to version 7. Commented Dec 1, 2011 at 6:39

2 Answers 2

4

This is absolutely not possible.

You have it a bit backwards: You'll have to call your Javascript from within the HTML document, not the CSS.

Use the JS to select the CSS then apply your width function.

Sign up to request clarification or add additional context in comments.

Comments

-1

Why not just have the javascript do it at document load using javascript outside of the CSS file?

You cannot mix CSS with JS, will not work at all.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.