Browser blocking Mathjax on app engine static page

不打扰是莪最后的温柔 提交于 2021-02-05 09:27:09

问题


I am trying to serve a static page containing Tex-style Math that is to be rendered by Mathjax. The pages are being served by a Flask app on Google app engine. Problem is - Chrome, Opera and Edge - all browsers are blocking Mathjax from rendering the Math, but it works properly if I manually unblock it from on top of the browser every time the page loads. The site works perfectly offline, but the problem occurs when the page is accessed through the app engine app. Any way to prevent the browser from blocking the script? Note that Mathjax is being loaded from the official CDN, but I have also tried using a local copy.

Example link: https://20200407t065833-dot-clip-sync-03.appspot.com/book_preview_chapter_1


回答1:


The main problem is that you're loading MathJax via http on an encrypted page using https - browsers will block such content for security reasons. On your local machine, you are probably using file:// or localhost to load the page, so this problem does not happen there.

On a side note, you are also using a very old version of MathJax (cdn.mathjax.org was retired a long time ago). Finally, the page markup is not actually valid HTML (though parsers will fix it).

Here's a working example.

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>TITLE MUST BE NON EMPTY</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  </head>
  <body>
    <h1>অধ্যায় ১</h1>
    <h2>বিভাজ্যতা <br>
    Divisibility </h2>

    <p>বিভাজ্যতা নিয়ে আমরা সবসময়ই জেনে বা না জেনে ভেবেছি। যেমন আমার \(10\) টা চকলেট থাকলে সেগুলো \(5\) জন বন্ধুকে সমানভাবে ভাগ করে দেওয়া যাবে, কিন্তু চারজনকে সমান ভাগ করে দেওয়া যাবে না। অথবা স্কুলের ক্লাসে \(45\) জন ছাত্র থাকলে তারা \(5\) বা \(9\) টা লাইনে সমানভাবে দাঁড়াতে পারে, কিন্তু \(4,6\) বা \(10\) টা লাইনে দাঁড়ালে সব লাইনে সমান সংখ্যক ছাত্র থাকতে পারে না। এই সাধারণ ধারণাগুলোই সংখ্যাতত্ত্বের ভিত্তি। কিন্তু সাধারন এই ধারনাগুলোই জন্ম দিয়েছে অসংখ্য অসাধারন সমস্যার। মানুষ তার কতগুলোর সমাধান করতে  পেরেছে। আবার কতগুলোর কোন কুল-কিনারা করা যায়নি। যেমন বলা যায় ফার্মার শেষ উপপাদ্যের কথা। এই উপপাদ্য বলে, \(n>2\) একটা পূর্ণসংখ্যা হলে এমন তিনটি স্বাভাবিক সংখ্যা \(a,b,c\) পাওয়া যাবে না যেন \(a^n+b^n=c^n\) হয়।  আপাত দৃষ্টিতে সরল দর্শন এই সমস্যার সমাধান করতে মানুষের লেগেছে প্রায় চারশ বছর! যদিও ফার্মা নিজেই চমৎকার একটি প্রমাণ আবিষ্কার করার দাবি করেছিলেন, তবুও তার সত্যতা যাচাই করা যায়নি।</p>
...
</body>
</html>


来源:https://stackoverflow.com/questions/61146721/browser-blocking-mathjax-on-app-engine-static-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!