JSPDF 2.3.0 with IE11 in SharePoint on premise not loading - internet-explorer-11

I am trying to use jsPDF.umd.js in SharePoint to create some pdfs in an enterprise environment.
Sadly I have to rely on IE11 in this environment.
I am loading the jsPDF with script tags
<script type="text/javascript" src="/sites/xxxx/polyfills.umd.js"></script>
<script type="text/javascript" src="/sites/xxxx/jsPDF.umd.js"></script>
and try to create an object with
new jspdf.jsPDF();
This works in Firefox and Edge, but Internet Explorer seems to not load the jsPDF.umd.js at all.
The error seems to be
SCRIPT1047: In strict mode, function declarations cannot be nested inside a statement or block. They may only appear at the top level or directly inside a function body.
File: jsPDF.umd.js, Line: 744, Column: 5
I am at a loss, because this works in ff and edge, but not in IE.
The sample (http://raw.githack.com/MrRio/jsPDF/master/#) site works with all browsers.
Is there a way to disable strict mode?
I never had problems with use strict before - though I do not know if and where it is activated.
I am not JavaScript developer - so maybe there is a completely different issue at work here.
edit:
the issue seems to be IE with javascript. I commented the lines with error from jspdf.umd.js out, and now I am getting a syntax error at line 847
let protection = 192;
maybe IE is using a pre ECMAscript 5 engine?
edit2:
navigator.userAgent
outputs
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Zoom 3.6.0)"
so I think I am in compatibility view - switching Document Mode seems to fix the issues - I don't know how to proceed from here yet, because this cannot be a general solution for all users.
edit3:
so the page contains
<meta http-equiv="X-UA-Compatible" content="IE=10">
so I will need to change that I guess.
Maybe these articles will help:
https://www.dannyjessee.com/blog/index.php/2020/03/rendering-a-single-sharepoint-page-in-ie-using-edge-mode/
https://paultavares.wordpress.com/2015/01/20/how-to-render-a-sharepoint-page-in-ie-using-edge-mode-without-changing-the-master-page/

From the description, I understand that JSPDF can work with the IE 11 or Edge document mode. But Sharepoint site contains the meta tag that loads the site in the IE 10 document mode. That breaks the JSPDF functionality.
To fix the issue, you need to load the site in the IE=edge mode.
You simply need to update your SharePoint's master page to target the latest version of IE, to update your master page, follow these simple steps.
Step 1: Download master page file.
Go to Site Settings.
Then to master pages and page layouts.
Look for the HTML version of your master page. If you are using Seattle as a master page for the site, look for the seattle.html file. If you're using the Oslo master page, then look for the oslo.html file.
Step 2: Update the master page code.
Open the downloaded file into a text editor of your choice, and look for the following meta-tag.
<meta http-equiv="X-UA-Compatible" content="IE=10" />
Update the value of the content attribute to have:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Now Save the file.
Note: The meta tag might be placed multiple times in your master page file, make sure to update them all.
Step 3: Upload master page file.
On the Master pages and page layouts click the ribbon bar, and click Upload Document button.
Now Choose the file you have just edited by clicking the Choose File button, then click OK to upload.
Another dialog will appear asking you to enter some information about the master page. Don't type anything, just click Check In button.
One last step you need to do is to make your changes available to all of your site visitors, which is to publish this master page.
To do that, Select your master page, and click the Publish button from the ribbon bar.
To proceed with publishing click OK on the next dialog.
Reference:
IE Compatibility with SharePoint and Office 365

Related

Programmatically retrieving the contents of the chrome://gpu url

I am trying to programmatically retrieve the contents of the chrome://gpu url.
As a start I tried to load up chrome://gpu from the command-line, but chromium refuses to start up with a url that is prefixed with a chrome: prefix.
Then I tried to out-clever that limitation by using a redirect page:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="7; url='chrome://gpu'" />
</head>
<body>
<p>Please follow this link.</p>
</body>
</html>
But that page, although it can be launched from command line, would not refresh for me.
Even clicking the link does not work, which leads me to determine that you cannot link to chrome://gpu at all.
When I tried right-click open-in-tab on the link, I get:
Which means that chromium is actively blocking access to it, unless it is typed out by the user.
I have two questions:
Can this block be disabled?
If not, how can I retrieve this information programmatically? Can I somehow feed artificial keystrokes into chromium?
Update 1
Tried to add virtual key-strokes with:
$ wtype test
Compositor does not support the virtual keyboard protocol
Update 2
I have gotten further: I can use ydotool to make chromium browse to chrome://gpu and then do Save-As, but that saves a nearly empty html page that references a gpu_internals.js script.
Is it possible to save the output of that script instead?
Access to the "chrome://gpu" URL is restricted and cannot be directly accessed programmatically. This restriction is in place to prevent malicious actors from manipulating the internal settings of the browser.
An alternative approach could be to use a headless browser like Puppeteer or Selenium to automate the process of retrieving the information from the "chrome://gpu" page.
I've found ydotool to be a good solution for this.
With it, you can automatically open a page to chrome://gpu and then click in the browser window, followed by Ctrl+A, Ctrl+C to retrieve to contents to the clipboard.
You can then use wl-paste from the wl-clipboard package to get it.

How to preview a static site?

With Ruby on Rails I can run rails s -p 3000 and preview my site at localhost:3000.
With React I can run npm start and view the site at localhost:8080.
What if I just have html and CSS files, how do I preview that?
On OSX, you can run a simple web server from any directory using this command:
python -m SimpleHTTPServer 8000
Then, you can hit the directory in your browser by going to http://localhost:8000/path/to/file.html
You can try click 2 times in index.html to open the file in browser.
Every time you update the code in sublime text, you need to reload the browser and the updates will be aplied.
This usually depends on your device/OS and what your eventual goals are, but usually you can either use (online) software that renders the HTML and the CSS for you (such as Brackets.io, etc.) whilst you are typing it (to live preview any modifications/additions), or you can put the documents live using a local webserver such as Xampp or OSXs built in simple web server, and check their respective localhost locations every time you save changes using your code editor.
You could also simply use online applications like Codepen, which can also render HTML and CSS, and even JavaScript. Codepen just today launched Codepen Projects which allows you to create entire website projects at their website. It is however, a pro (paid) feature.
Here's a short overview of code playgrounds that offer the functionality you requested (by no means an exhaustive list):
JSFiddle
CSSDeck
CodePen
JSBin
And ofcourse you can insert Snippets here on StackOverflow, which is also able to render HTML and CSS (and JS).
If you really only use HTML and CSS, previewing in a browser is also possible, opening the .html file by double clicking and opening in Internet Explorer, Chrome, etc.

How can I determine the Reason IE is going into Compatibility View Mode and prevent it from happening?

Okay, here are the facts regarding our problem:
The web site we are working on is designed to use modern HTML5 features. This includes indexedDb.
We are using the following HTML right at the top of each page:
<!DOCTYPE html><html><head><meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
All our users are using the same version of IE11.
We have 200+ active users who use the site, and for most of them, everything works just fine. The browser stays in "Edge" mode.
So far though, 3 of those users' browsers started opening the pages on the site in Compatibility View Mode instead of the default Edge mode. It was working for them fine previously.
If any other user goes to any page that those 3 users went to, they open fine (in Edge mode).
I created a super-simple diagnostic page devoid of CSS, HTML5 features, etc., when the users who are having the problems go to this page, it STILL going into compatibility view mode! It seems once the damage has been done, the browser wants to go into compatibility view mode for that domain regardless of the page content!
We've tried deleting Browsing History in the user's browser including cookies and website data... it does not fix the problem.
Restarting the PC does not work.
We do not have enough security to access any registry settings or directories where the browser stores its files.
So for starters, the question is, what steps can we take to figure out WHY their browsers when into compatibility mode in the first place. The only things I'm finding are vague error messages in the F12 console about using some feature or other improperly. No info about what feature or what error it caused.
And then, if that can be resolved, for users already in this mess, is there any viable steps we can take to get them so they see the site in Edge mode once again.
I'll be grateful for any help I can get on this. I am really stumped on this one!

IE 11 Compatibility Issue, setting document mode to 9 by default after making changes also in meta tag

I made changes in the master page of my SharePoint site. I have added a meta tag in my header like so:
<meta http-equiv="X-UA-Compatible" content="IE=8,9,10,11" />
and I've also changed the doctype, but the emulation is still rendering in IE9 document mode.
Attached is the screenshot.
Please let me know where I need to make changes. This site is using custom master page. I have updated it in the Custom as well as the V4 master page but no luck.
A few suggestions:
Set the content attribute of the <meta> tag to "IE=8" instead of "IE=8,9,10,11".
Make sure that the <meta> tag containing your IE rendering directive is the first <meta> tag in the header.
To prevent the F12 developer tools window from forcing the page into a particular document mode, close all instances of Internet Explorer, then start it up again and revisit the site without the F12 developer tools open. Open the F12 developer tools to check the page document mode only after the page has loaded.

vb.net Webbrowser Control not displaying Javascript

I have tried this on numerous pc's and are receiving the same error. My webbrowser control isnt displaying javascript or jquery.
Here is a example:
when i visit this url in my browser: https://binarykings.co.uk/traderoom-aspx, it looks great with the charts and prices etc.
example: http://i.imgur.com/1Lmq4em.png
same in internet explorer: http://i.imgur.com/3KP864X.png
however in my vb.net webbrowser control it looks like this: http://i.imgur.com/qjme2Yg.jpg
What is causing this ? Its not just this site but any other site that has a similar way of displaying things via jquery/javascript.
I do have script errors suppressed however when i disabled this and clicked yes to the errors manually it still displayed the same empty page.
Thanks
The WebBrowser control uses the Internet Explorer rendering engine. But by default, for compatibility reasons, it is stuck using the IE 7 rendering engine, even if you have a later version of the browser installed on your computer.
There are a couple of ways to convince it to use a newer version of IE to render the page. One involves editing the registry, while the other involves modifying the web page.
In general, it is best to avoid attempts to solve local problems with global solutions like registry edits. There might be another app running on the same machine that uses the WebBrowser control and relies on the behavior of the IE 7 rendering engine. If you go changing global settings, you'll mess up that other app.
Therefore, the best solution, if possible, is to edit the web page. This is quite simple, and probably a good idea anyway. All you need to do is add the following code inside of the <head> section:
<meta http-equiv="X-UA-Compatible" content="IE=9" >
If you absolutely must use the alternative approach of editing the registry, you'll find the information you need here in the documentation.