What's wrong with that code https://dartpad.dartlang.org/59c9ac878a0335fdcffb or with DartPad?
It produces
Uncaught TypeError: constr is not a function
in the CONSOLE.
https://github.com/dart-lang/dart-pad/issues/690
Yes, part of dart:js is implemented in javascript files, which we're not able to load. You can see error messages to this effect in the devtools console.
You could try hosting those javascript files on a CDN, and referencing them from your html file - that might work.
Related
For the sake of debugging the javascript-part of a Rails 6 (version 6.0.0.rc1) web application I want to use my custom javascript functions also in the Chrome console (aka. Inspect).
Back when I used just static HTML files to build a website (as opposed to using a web-framework like Rails as of right now) you would simply embed the JS file in the DOM like this
<!-- custom JS -->
<script src="js/custom.js"></script>
and could instantly access and execute all custom functions that were placed in this file.
Background:
The JS file is placed at the correct rails 6 specific directory as provided in this article: How to require custom JS files in Rails 6
Note:
The rails 6 application also uses the JS file already, since the browser shows the console log message.
Here is the full content of the JS file:
// app/javascript/packs/custom.js
console.log("loaded custom.js successfully")
function sayHello () {
console.log("Hello good Sir or Madam!")
}
Expectation: I am expecting to open the browser's (Chrome) console and be able to use the sayHello() function in the console.
However, when I do so, I get an error message in the console stating:
Uncaught ReferenceError: sayHello is not defined
Try something like
sayHello = ()=>{
console.log("Hello good Sir or Madam!");
}
then you can evoke in console:
>sayHello();
I am just getting started on a new project which I would like to write in ReactJS. I am trying to use Broserify to bundle everything so that I can have it in multiple js files.
However, when I try to bundle my react file (browserify main.js > bundle.js), I get this error:
"Error: Parsing file /Users/Kathleen/Documents/Referral_Site/main.js: Unexpected token (3:4)"
main.js looks like this:
var Lander = require('./lander');
React.render(
<Lander />,
document.getElementById('content')
);
What's breaking the parser? Thanks in advance!
EDIT: also, I included react in the surrounding html like this:
<script src="http://fb.me/react-0.12.2.js"></script>
is there some way that I need to include it in main.js as well?
You must compile JSX to plain JS first, there is plugin for browserify.
https://www.npmjs.com/package/reactify
I am building Firefox extension, that creates single XMPP chat connection, that can be accessed from all tabs and windows, so I figured, that only way to to this, is to create connection in javascript module and include it on every browser window. Correct me if I am wrong...
EDIT: I am building traditional extension with xul overlays, not using sdk, and talking about those modules: https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules
So I copied Strophe.js into js module. Strophe.js uses code like this:
/*_Private_ function that creates a dummy XML DOM document to serve as
* an element and text node generator.
*/
[---]
if (document.implementation.createDocument === undefined) {
doc = this._getIEXmlDom();
doc.appendChild(doc.createElement('strophe'));
} else {
doc = document.implementation
.createDocument('jabber:client', 'strophe', null);
}
and later uses doc.createElement() to create xml(or html?) nodes.
All worked fine, but in module I got error "Error: ReferenceError: document is not defined".
How to get around this?
(Larger piece of exact code: http://pastebin.com/R64gYiKC )
Use the hiddenDOMwindow
Cu.import("resource://gre/modules/Services.jsm");
var doc = Services.appShell.hiddenDOMWindow.document;
It sounds like you might not be correctly attaching your content script to the worker page. Make sure that you're using something like tabs.attach() to attach one or more content scripts to the worker page (see documentation here).
Otherwise you may need to wait for the DOM to load, waiting for the entire page to load
window.onload = function ()
{
Javascript code goes here
}
Should take at least diagnose that issue (even if the above isn't the best method to use in production). But if I had to wager, I'd say that you're not attaching the content script.
I need to access TinyMCE content from Dart. The Dart js library should enable me to do so through TinyMCE's Javascript API. However, I'm stuck at how to initialize TinyMCE from Dart because I found no instruction on how to construct a TinyMCE instance in Javascript.
According to TinyMCE API, the following JS code should return TinyMCE content:
tinymce.activeEditor.getContent();
Thus, I believe this Dart code should do the same:
var content = js.tinymce.activeEditor.getContent();
However, running this code returns the following error:
Internal error: ...: Error: line 149 pos 20: identifier 'js.tinymce'
cannot be resolved var content =
js.tinymce.activeEditor.getContent();
The editor complains about the undefined tinymce variable. Any idea how to fix this? Thanks.
The js-interop equivalent of JavaScript tinymce.activeEditor.getContent(); is :
js.context.tinymce.activeEditor.getContent();
Basically js.context returns a reference on the JavaScript window object.
I am trying to use highcharts.js in a Meteor.js application but can't get past the initial referencing errors. My console is showing the following:
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:3000/highcharts.js". localhost:9 Uncaught SyntaxError: Unexpected token < :3000/highcharts.js:1 Uncaught TypeError: Cannot set property 'innerHTML' of null highcharts.js:55
I have the highchart.js file in my client/lib directory and my highchart javascript code in my app.js file in the client directory. I have tried moving the highchart.js file to other locations, but it has dom references that are a problem when in server scope, so ended up in my client/lib directory.
Any thoughts on how to resolve this initial configuration/reference problem would be greatly appreciated!