C# WPF Application webbrowser can't run angularjs - javascript

I have made a WPF application with a browser and set it to go to a website which is using firebase and angularjs. When I run the program I get errors such as "Unable to get property 'prototype' of undefined or null reference" and it shows the source of this error as angular.min.js. Another error is within the firebase.js file and it just says "Script error". The website works perfectly on actual browsers such as Chrome or even IE11. How can I fix these errors?
Thanks in advance!

Show me your html file where you import angular.min.js and firebase.js.
Maby can be fixed with a DOCTYPE:
<!DOCTYPE html>
And a meta tag:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Related

"Missing PDF" every time I use Grapecity PDF Viewer

I'm building an app that will have an interactive PDF form on a server (in HTML, CSS, JS). I have been trying to use the Grapecity PDF viewer, but to no avail. I've followed the documentation to a T, using these resources: one, two, three.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<title>GC Viewer Demo | PDF Plugin</title>
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/2.8.94/css/materialdesignicons.min.css">
<script>
function loadPdfViewer(selector) {
var viewer = new GcPdfViewer(selector, { renderInteractiveForms: true });
viewer.addDefaultPanels();
viewer.open("HelloWorld.pdf");
}
</script>
</head>
<body onload="loadPdfViewer('#root')">
<div id="root"></div>
<script type="text/javascript" src="gcpdfviewer.js"></script>
</body>
</html>
I currently have the "HelloWorld.pdf" and the gcpdfviewer javascripts in the same folder as the above index.html but every time I test the code in the browser, the PDF viewer loads, but the PDF doesn't, giving me an error that states "missing PDF."
This is really bothering me because the PDF is exactly where it's supposed to be, I think.
I'm currently not using a license key, but the documentation makes it seems like I don't need one. Maybe that's the issue.
Any ideas?
Edit - Here are the console errors in Chrome:
The pdf worker has been disabled. Note, rendering PDF in foreground thread can slow pdf viewer performance.
ce # gcpdfviewer.js:1
index.html:1 Access to XMLHttpRequest at 'file:///C:/HelloWorld.pdf' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
HelloWorld.pdf:1 Failed to load resource: net::ERR_FAILED
index.html:1 Uncaught (in promise) V
Firstly, the issue is not because of the non-license version.
The issue occurs because you are trying to execute the sample locally using the file system. To overcome this issue, you should host the application on a local server and the Pdf will be loaded in the PdfViewer.
While loading a Pdf in the PdfViewer, there is XMLHttpRequest which checks the origin. This is null in the case of the file system. Hence, throws the error on accessing the file.
Here is the documentation link for configuring the PdfViewer:
https://www.grapecity.com/documents-api-pdf/docs/online/view-pdf.html
Regards,
Manish Gupta
Thank you for using GCPDF Viewer. Is the filename exactly the same, it might be case-sensitive OS?
Can you look in the browser network tab and watch for the request going to retrieve the PDF file, is it looking in the same location where you have placed the file.
which server software are you running? is it serving the PDF file?
http://www.grapecity.com
As stated earlier, for security reasons, it is not possible to access files on your local filesystem via JavaScript, you need to set up a web server and open PDF files using the web server url.
But if you really want to do it, there is another workaround - start Chrome with disabled web security, and then open the index.html page from the local file system, for example:
"c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir="C:/temp/CustomChromeSession" --disable-web-security "file:///C:/temp/gcpdfviewer-test/index.html"
Note, this workaround is not recommended due to security reasons and this approach can be disabled by browser developers later.
Here's a screenshot of how it works

Play cannot reference external javascript

A very basic question
Cannot load external javascript resource on server
I am working on a Play framework project. I've made some basic html view with some Javascript. It works correctlly when I have my js code in the actual view.
However, when I tried moving js code to a separate file and load it using
<script> src="main.js" </script>
It works correctly when opened using plain chrome browser. However when I run it on server and it fails and chrome dev console prints the following message
GET http://localhost:9000/main.js 404 (Not Found)
I've tried setting up a GET request on targer URL but cannot pass main.js as an arguement to Ok method
def getmainJs()= Action {
Ok()
}
Is there a painless way to access the js code or do I have to go through the process of setting up the JavacriptRouter menntioned here. The app is only going to be 2 views to I kind of don't care about scalability
I created an example on how to serve a Javascript file:
Routes:
GET /foo sk.ygor.stackoverflow.q53319493.controller.ApplicationController.foo
GET /assets/*file controllers.Assets.versioned(file)
View:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script src="#routes.Assets.versioned("main.js")"></script>
</body>
</html>

Got "'d3' is undefined" error when I remotely access my server in IE

With Internet Explorer v11, I got "'d3' is undefined" error when I accessed to my d3 web site which was deployed in remote IIS7 server.
However, with Internet Explorer v11, there was no this "'d3' is undefined" error when I accessed to my d3 web site which was deployed in my local IIS7 server.
And, with Firefox and Chrome, there was no this "'d3' is undefined" error when I accessed to my d3 web site which was deployed in my both remote and local IIS7 server.
That is, on my local server with "localhost", my d3 website works fine. But, when I tried to access the server from remote computer, I got this "'d3' is undefined" error. This issue only happens in IE, not in Firefox and Chrome.
I have tried the following ways, but this issue still exists.
< meta http-equiv="content-type" content="text/html; charset=UTF-8" >
< script src="JavaScript/d3.v3.min.js" charset="utf-8 >< /script >
< script src="http://d3js.org/d3.v3.min.js" charset="utf-8" >< /script >
Then I found that this issue was caused by this code in d3.v3.js:
......try {
d3_document.createElement("DIV").style.setProperty("opacity", 0, "");
} catch (error) {
var d3_element_prototype = this.Element.prototype, d3_element_setAttribute = d3_element_prototype.setAttribute, ......
This code create the error "Object doesn't support property or method 'setProperty" because d3_document.createElement("DIV").style doesn't have setProperty() in IE11 with .NET Framework 3.5
But how to fix this? Can anyone help me? This issue have bothered me several days.
Many many thanks.
Greg.

Unexpected Illegal Token in javascript from CDN - scripts contains only garbled text

I'm trying to host a webpage on my PC (Running Windows 7), and intend to use bootstrap css/javascript library, but I am having trouble using the bootstrap javascript library from a CDN. Here is a minimal example, index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello world</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
Hello world
</div>
</body>
</html>
I have tried to host the page on localhost using both "python -m SimpleHTTPServer" and using node.js + express, but I get the same result, where I get the message "Uncaught SyntaxError: Unexpected token ILLEGAL" with reference to bootstrap.min.js:1 in chrome's javascript/html debugger.
If I open bootstrap.min.js it only shows lots of chinese signs (which is translated to meaningless text in google translate). All this goes for other CDN scripts also, such as socket.io.
*Edit 1:
I tried downloading the source and loading the bootstrap.min.js script locally
with
<script src="/js/bootstrap.min.js"></script>
but I get the excact same problem as before.
I had the same problem on my own local page. I thought it might be an issue with the way I was loading bootstrap or jquery as these files were showing what looked like Chinese characters in Chrome Dev tools, even though the js and css files looked ok when loaded from a URL. Googling "Unexpected token ILLEGAL" came up with this question on Stack Overflow, so I'll answer. The issue turned out to be invalid characters in my HTML.
My method to solve was to create a dead simple page from scratch and add the features from the failing page one by one until it resembled my failing page. In the end, the source looked identical in a text editor, but the newly constructed page worked fine while and the original page had the "unexpected token" error in Chrome console. So I compared the files and found some hidden characters (which I had copy and pasted from a web page snippet) which were causing the failure.
When I copy and paste your HTML above into a text file and open it in Chrome, it displays correctly.
In my case the character coding made the same issue.
As soon as I forced the output to save as UTF-8, the issue gone.

New phonegap project failing with TypeError: undefined is not a function on line 1

Trying to get phonegap to work on an iPhone.
With a completely blank project, except for jsconsole for debbuging and the cordova.ios.js file, I keep getting errors as soon as the app loads:
file:///var/mobile/Applications/19E49099-C481-44B4-8803-07A0390EA3B3/pplats.app/www/index.html:1link
TypeError: 'undefined' is not a function
I cant get anything more out of the stacktrace. Why could I be getting a TypeError? Completely running out of ideas here.
The HTML file:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="cordova.ios.js"></script>
<script src="http://jsconsole.com/remote.js?79F01FAA-19A6-40C2-B32F-7FEF1D5E3998"></script>
</head>
<body>
testing......
</body>
</html>
What does your project directory structure look like?
My guess is that this is related to the src="cordova.ios.js" link, have you tried specifying an absolute or root-relative (/path-to-file/cordova.ios.js) path to the js file?

Categories