I have a local IIS site where i developed some code with PDF.js. There it worked fine to load a specific PDF and read the text contents from it.
Then I copied everything to the a library in a SharePoint Server (thats the only difference, IIS vs SharePoint) and changed all references. The code does not throw any Errors, with debugging level info it just prints
Info: Cannot use postMessage Transfers
to the console. Adding a console.log line into the PDF.js catch block of the promise did not result in any new information. It doesn't even get to the first logging inside the then:
var pdfobj = PDFJS.getDocument(docPath);
pdfobj.then(function (pdf) {
console.log(pdf);
any ideas?
EDITS: Updated from PDF.JS 1.1 to 1.2
There are not many error logs in PDF.js. I accidently hardcoded a wrong URL where even the server is non existent... and no error log, not even the then(...).catch(...) is called?
It is working now in Firefox but not in IE and I cannot see any reason for this. The Info message about Cannot use postMessage Transfers is also only displayed in IE (using IE 11).
It does work now. I am not sure what I did to fix it, but I will update this answer when I know. I think it has something to do with the directory structure of the PDF.js files. Previously I just uploaded all JS files (there were no errors though).
Still there is no exception handling when the PDF does not exist.
Related
I am trying to import a json file from a website using p5.js, and i thought it would be quite easy, however when i tried it i realized the json was actually just in plain text on the page (It is the only thing on the page). I checked chrome web tools to look at index.html, but i was greeted by "(index)", is it a problem with google or am i just going to have to use something else than this?
function preload() {
httpGet('leaderboard.popcat.click', 'json', function(response) {
});
}
//there are the setup and draw functions aswell
I got an error when i ran the code aswell, it was
Error: JSONP request to url failed
here is a picture of the page btw, (the url is leaderboard.popcat.click)
EDIT: The main problem i am having is that there is no file in https://leaderboard.popcat.click/, not the getting of json.
The network tab says no such url exists, and i believe that is because of the fact that i didn't specify a file.
Here is the console output aswell
I solved my issue by starting chrome in no-cors mode or whatever it's called AND using the full path of the website. I got it into no-cors mode by making a shortcut with this link
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir=~/chromeTemp"
and running it as an administrator
I am using library called arbor.js(beautified). It contains the following line of code,
i = new Worker(<path to arbor.js>);
At this point an error is thrown, and the following message is reported in Firebug,
"Could not get domain!"
The line which gives this error is 258. The arbor_path() function on that line returns "js/", so effectively function called is i = new Worker("js/arbor.js").
This used to work perfectly in Firefox 7. Does anybody know how to solve it, or what the problem could be?
You're running into https://bugzilla.mozilla.org/show_bug.cgi?id=683280
It'll be fixed in Firefox 9 in about a month....
I came across the same thing, however I only noticed the problem on one of my computers, and not the other (both running Firefox 8), so I started to explore a little bit. It turns out, the computer the workers were working on is using a subdomain of localhost (and modified HOSTS file). I just tested it out as simply as I could think of, just adding localhost.com to the HOSTS file, and accessing the site through that and the workers are doing ok with it. I didn't create any virtual hosts or directories, just mapped localhost.com to 127.0.0.1. If you are running on Windows (or otherwise can do the same kind of mapping) you might want to give that a try as a temporary solution.
Edit: In response to chinmayv's comment: Something I noticed I have set in the HOSTS file is the IPv6 version of the local IP address, so there is both: ::1 localhost and 127.0.0.1 localhost, as well as the one to get the worker running on FF8 127.0.0.1 localhost.com. I don't know why this would matter, however. I just did a fresh install of Apache, so I don't think there is any setting that could account for the difference in behavior. Are you still getting the 'Could not get domain!' error? Maybe there is an absolute URL in the script somewhere that is throwing it off?
I have the following simple jQuery:
$.get('Data.csv', function(data) {
alert(data);
});
Data.csv is stored in the same folder as the html file which accesses it.
If I run this in all browsers when the url is a domain (i.e. www.mysite.com/path/to/file), then the alert will display a string value of the contents of Data.csv.
If I create a hosts file link to the local folder (i.e. host.mysite.com/path/to/file) then alert will display a string value of the contents of Data.csv in all browsers.
If I run this in IE 9 when the url opens the file locally (i.e c:\path\to\file) then the alert will display a string value of the contents of Data.csv.
However, if I run this in FF or Chrome when the url opens the file locally (i.e file:///c:/path/to/file) then the alert will display [object XMLDocument].
Does anyone know why this is and how to open the local file as a string in FF and Chrome?
n.b. - I have tested this in order to rule out cross-platform-security issues. I don't think that that is the cause because otherwise it would not assign the content of the csv file at all.
Thanks in advance.
You're running into issues with the Same Origin Policy. If you look into your browser's console, you'll see something along the lines of Origin null is not allowed by Access-Control-Allow-Origin.
There's two possible fixes:
Run your stuff on a local web server like XAMPP, MAMP or the like.
Disable all web security on Chrome Startup, which you obviously don't want to do in real life. Wouldn't work in FF, either. So, stick with 1. ;)
I am getting (NS_ERROR_DOCUMENT_NOT_CACHED) error when I try to access the Javascript code through firefox.I get this error in the contents tab of HTTPFOX.
I googled and set the parameters of browser in config file as specified in this site but it still doesn't work.
http://code.google.com/p/httpfox/issues/detail?id=20
Can somebody suggest whats going wrong since the same code works fine for safari browser..
If anyone is interested in a solution to this, I believe it's to do with the plugin noscript. Disabling it fixed this, but I have yet to work out what part of noscript was causing the issue. Will update if I find out.
Edit:My issues was with a twitter auth callback. In the Advanced settings of noscript under ABE, in the SYSTEM ruleset, on the line "Accept from LOCAL" I added "*.twitter.com". This allowed callback requests from *twitter.com to return to a local address.
On my macbook I had to uninstall firefox completely to correctly get the content of an ajax response with httpfox. This also implies to remove the firefox profile bij removing this Firefox folder (I could only find it via the terminal and not via Finder):
/Users/<YOURUSER>/Library/Application Support/Firefox
Then install firefox again and install the httpfox add-on.
I tried many cache settings also by entering about:config in the firefox URL however without succes. Be aware that removing the profile settings like I describe will also remove all your personal firefox customization. It concerned firefox 18.0.2 and httpfox 0.8.11.
We used to get the same error when our JavaScript made an XMLHTTPRequest to the server. On the server side, we had java, and the java response, the content type was not explicitly set to "text/html". When that was done
resp.setContentType("text/html");
the error went away.
I get the following error in Chrome's developer tools window when I try to set a cookie using this jQuery plugin:
Uncaught Error: SECURITY_ERR: DOM Exception 18
What does this error mean and how can I fix it? I get the same error when I use this jQuery plugin.
You're most likely using this on a local file over the file:// URI scheme, which cannot have cookies set. Put it on a local server so you can use http://localhost.
I also had this issue while developping on HTML5 in local.
I had issues with images and getImageData function.
Finally, I discovered one can launch chrome with the --allow-file-access-from-file command switch, that get rid of this protection security.
The only thing is that it makes your browser less safe, and you can't have one chrome instance with the flag on and another without the flag.
You can also "fix" this by replacing the image with its inline Base64 representation:
img.src= "data:image/gif;base64,R0lGODlhCwALAIAAAAAA3pn/ZiH5BAEAAAEALAAAAAALAAsAAAIUhA+hkcuO4lmNVindo7qyrIXiGBYAOw==";
Useful, when you do not intend to publish the page on the web, but instead use it on local machines only.
Faced with the same situation playing with Javascript webworkers. Unfortunately Chrome doesn't allow to access javascript workers stored in a local file.
One kind of workaround below using a local storage is to running Chrome with --allow-file-access-from-files (with s at the end), but only one instance of Chrome is allowed, which is not too convenient for me. For this reason i'm using Chrome Canary, with file access allowed.
BTW in Firefox there is no such an issue.
This error pops up, if you try to create a web worker with data URI scheme.
var w = new Worker('data:text/javascript;charset=utf-8,onmessage%20%3D%20function()%20%7B%20postMessage(%22pong%22)%3B%20%7D'); w.postMessage('ping');
It's not allowed according to the standard: http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#dom-worker
I had this issue when using the history API.
window.history.pushState(null, null, URL);
Even with a local server (localhost), you want to add 'http://' to your URL so that you have something similar to:
http://localhost...
I wasn't completely happy by the --allow-file-access-from-files solution, because I'm using Chrome as my primary browser, and wasn't really happy with this breach I was opening.
Now I'm using Canary ( the chrome beta version ) for my development with the flag on.
And the mere Chrome version for my real blogging : the two browser don't share the flag !
One can also receive this error if using the new (so far webkit only) notification feature before getting permission.
First run:
<!-- Get permission -->
<button onclick="webkitNotifications.requestPermission();">Enable Notifications</button>
Later run:
// Display Notification:
window.webkitNotifications.createNotification('image', 'Title', 'Body').show();
The request permission functions needs to be triggered from an event caused by the user, otherwise it won't be displayed.
I was been getting that error in mobile safari when using ASP.NET MVC to return a FileResult with the overload that returns a file with a different file name than the original. So,
return File(returnFilePath, contentType, fileName);
would give the error in mobile safari, where as
return File(returnFilePath, contentType);
would not.
I don't even remember why I thought what I was doing was a good idea. Trying to be clever I guess.