2

i want to display some source code on ajax loaded page via Facebox plugin.

But if i try to add script tag

<script src="src/prettify.js"></script>

Facebox remove all script tags in loaded page.

So i need pure CSS based solution for syntax highlighting or solve removing of script tags by facebox.

Thx for any help.

2
  • 1
    css can't highlight code, since that'd just be "text" within a block. css affects blocks. with a few exceptions, css can't affect individual characters or words in a block of text. and what it CAN do to those individual chars/words isn't enough to support highlighting of arbitrary text. Commented Nov 23, 2012 at 15:37
  • Have you tried to put the javascript and script tag in the body of the opening page (not the one loaded by ajax)? Commented Jul 11, 2013 at 18:41

1 Answer 1

1

Browsers don't execute script tags pulled in via AJAX: Inline jQuery script not working within AJAX call

The CSS only solution would be to manually wrap your code in spans and set all the coloring in CSS, which is definitely not ideal.

The best solution here would be to include <script src="src/prettify.js"></script> on the main page doing the Facebox ajax calls and just making sure that prettify is triggered on the AJAXed content after it's pulled in like so:

$(document).bind('beforeReveal.facebox', function() {
    prettyPrint();
});
Sign up to request clarification or add additional context in comments.

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.