"Unknown error" in my Chrome extension - html

I am writing (or attempting to write) my first Chrome extension, and I cannot figure out this error I keep getting. My background code is
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
console.log('works?');
chrome.tabs.executeScript(null, {code:"document.body.style.fontSize = 20"});
console.log('print again');
</script>
</body>
When I try to run this extension I get the error:
Error during tabs.executeScript: Unknown error. extensions/extension process bindings.js:85
Does anyone have any idea what this could possibly be or how to fix it? I get no error when I do not include the line chrome.tabs.executeScript, and I get the error no matter what I write for the parameters of chrome.tabs.executeScript.
I also get the error when I include chrome.tabs.executeScript inside a function that is called whenever the browserAction is clicked
Any help would be much appreciated, thank you!

You are injecting code into selected tab right when background page loads for the first time, which happens on chrome://extensions page where you cannot inject anything.
Not sure why you are still getting error inside browser action listener, maybe you have extensions page still opened?

Related

Wix iFrame always gets "Secured Connection Failed"

I've added an HTML iFrame in Wix (like many many times before) and it always gets a "Secured Connection Failed" error with code: SEC_ERROR_REVOKED_CERTIFICATE
Even with the simplest code that does nothing.
screenshot
Has anyone else got this? Any workaround?

Bokeh Inline Embedding, 'Failed to load resource'

I'm having an issue with embedding Bokeh inline. Particularly, there is an issue with loading the resources from the 'link' tag (refer to html snippet below). For some reason, when I try try to embed a Bokeh plot inline, the following error occurs: 'Failed to load resource: the server responded with a status of 404 (Not Found)', referencing this link - https://cdn.bokeh.org/bokeh/release/bokeh.min.css.map
However, the above address is different from the one I indicate in the link tag (it omits the bokeh version at the end). I have no idea why this error occurs, it's the first time that this happens. I have previously used inline embedding successfully on a number of occasions.
<head>
<link href="https://cdn.bokeh.org/bokeh/release/bokeh-0.12.1.min.css" rel="stylesheet" type="text/css">
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-0.12.1.min.js>
</script>
</head>
EDIT
I am trying to use inline embedding together with jQuery (I would like to display different Bokeh plots without reloading the entire page every time).
When I looked for further error details in the console, I found the following error: "Error rendering Bokeh model: could not find tag with id..."
If it's of any relevance, here is the jQuery script in my html:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type=text/javascript>
$(function() {
$('a#process_input').bind('click', function() {
$.getJSON('/background_process', {
proglang: $('input[name="proglang"]').val(),
}, function(data) {
$("#result").html(data.a);
$("#r").html(data.b);
});
return false;
});
});
</script>
Where 'data.a' and 'data.b' are the Bokeh-generated script and div tags, respectively.
Any suggestions or advice would be much appreciated!
Best guess is that the script is executing first/early, before the <div> is inserted into the DOM. You will need to find a way to guarantee that the <div> is available by the time the the script executes.
As an aside the partial load use case was not really envisioned when the componenent function was created. If you want to do partial loads, it might be better to serve the doc JSON and then calling Bokeh.embed.embed_items directly on from JavaScript somehow. But it would probably take some experimentation and discussion and back and forth to get that working, which SO is not very good for. I'd encourage you you bring this topic to the public Discourse for further discussion.

Angular JS Click Event is not working

I am for the first time trying to work on Angular JS . I designed a HTML form which contains hyperlink . Now i want to register a click event on the same hyperlink but it is not happening. I have added CDN reference for the angular JS at the end of Body and adding Javascript code in the head section of the HTML page.
Here is My Hyper Link markup..
<div ng-app="LoginApp" ng-controller="LoginController" class="top-big-link">
<a class="btn btn-link-1" href="" ng-click="Register()">Register</a>
<a class="btn btn-link-2" href="" ng-click="Login()">Login</a></div>
and here is my Angular JS Script in the Head Section ..
<script type="text/javascript">
var app = angular.module('LoginApp', [])
app.controller('LoginController', function ($scope) {
$scope.Register = function () {
$scope.Message = "Button clicked."
}
<pre></pre>});
</script>
Also on checking the developer console of Chrome i am getting following error message ..
Uncaught SyntaxError: Unexpected token <
angular.js:38 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.9/$injector/modulerr?p0=LoginApp&p1=Error%3… ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.3.9%2Fangular.min.js%3A17%3A350)
Please help me to resolve this ..
There is no problem with your event handler: the error says "Syntax Error: Unexpected <". So your angular application did not even start, because the javascript code of your application is invalid.
This particular error, usually means your browser is trying to interpret some HTML code as javascript.
Start by removing the <pre></pre> from your controller code if that's not an artefact from copy pasting in stackoverflow.
If that does not work, it means that you are referencing another HTML file (most likely a 404 error) in a <script src="..."></script> somewhere in your code, or that you have a syntax error somewhere else.

How to see what's <omitted> in Chrome debug console

I am using Knockout.js, and the most important part of the error message is (nowadays) often hidden under the <omitted> part. I tried hovering over, and clicking a lot of stuff, but I can't find a way to see the full message. Does anyone have a tip?
Thanks in advance!
PS: I'm looking for a fix within the Chrome settings. So without cluttering my code with extra window.onerror stuff or otherwise. I don't want to clutter my code just because the Chrome development team thought it was a good idea to omit debug text :S
For a code hack, see this answer: https://stackoverflow.com/a/22218280/647845
Here's a little bit of code that will output the whole error message:
window.onerror = function (errorMsg, url, lineNumber, columnNumber, errorObject) {
if (errorObject && /<omitted>/.test(errorMsg)) {
console.error('Full exception message: ' + errorObject.message);
}
}
You can execute this in the development console in Chrome, so it doesn't have to be in the actual code of your web page.
Use Firefox. And vote up for this issue in the meantime:
https://code.google.com/p/chromium/issues/detail?id=331971

Make a back to previous url link in error 404

I have many pages on my website with some 404 errors because some pages are down under construction. How can i add something to my 404.html page to redirect the user back to the page they came from before they come to visit the 404.html
You can use javascript. Check this:
http://www.w3schools.com/jsref/met_his_back.asp
<script>
function goBack()
{
window.history.back()
}
</script>
<body>
<button onclick="goBack()">Go Back</button>
</body>
If you want to redirect the user back automatically, just use the history.back() method, but instead make it a script that runs onload:
<body onload="history.back()"></body>
You should probably only run this function after a couple of seconds though, otherwise the reader would have no idea what happened to them, and they'll just keep trying that link. To make the function run after 5 seconds, change your onload to:
setTimeout('history.back()', 1000*5)
the multiplication by 1000 is to change seconds to milliseconds (setTimeout works with milliseconds only).
Is this question about adding a back button, or about adding something to the 404 error page?
If it's the latter this may be a solution if you are using apache: https://www.digitalocean.com/community/articles/how-to-create-a-custom-404-page-in-apache