JavaScript inserted using HTML macro cannot be executed

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

Some JavaScript (specifically those with functions) inserted using the HTML macro cannot be executed upon saving a Confluence page. When previewing the page (using the Editor), the JS can successfully be executed.

Diagnosis

This issue only occurs in Chrome. After saving the page, going to Developer Tool > Console will produce the following error:

Refused to execute a JavaScript script. Source code of script found within request.

Cause

The error is thrown when the page is saved via a POST and then retrieved via a GET. This is actually a security measure put in place by the Chrome browser in order to prevent XSS (cross-site scripting) attacks.

For more information regarding this, please refer to the following links:

Resolution

Refreshing the page will resolve this issue. The JS can actually be executed upon refresh or upon normal viewing.

Last modified on Feb 26, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.