Processing working only on Firefox - javascript

I'm working on a website in HTML5 CSS3 but I can't make my processing sketch work on other browsers than firefox.
Here is my code:
<!DOCTYPE html>
<html>
<head>
<title>Project</title>
<script type="javascript" src="processing.js"></script>
</head>
<body>
<canvas data-processing-sources="accueil.pde"></canvas>
</body>
</html>

Just answering if someone have the same error than me:
Processing sketchs work only in firefox browser if you're in localhost.
If you want to try it on other browser you need to host your website.

Related

Tab kill function in JavaScript

I'm the one who started JavaScript yesterday.
I made code like this.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<script>
alert('Hello world \nNice to meet you \n');
</script>
</body>
</html>
However, after the code was finished, it was inconvenient to only leave blank pages.
Is there a function in JavaScript that kills the running browser tab?
I use Windows as the operating system and Chrome as the browser.
========
'Window.close();' in the last line of code I added it, but nothing happened.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<script>
alert('Hello world \nNice to meet you \n');
window.close();
</script>
</body>
</html>
window.close() will close the current tab.
Refer this stackoverflow question to get an idea why window.close() doesn't work for you.
And I also suggest you to clear the cache and sessions and try again.

Kinvey not working on iPhone and iPad

I'm using Kinvey's backend services accessing by their Javascript API. Initialisation of Kinvey works fine in any PC browser (Safari, FF, Chrome) and also on FF mobile and Chrome mobile. I got this error on iPhone's Safari and iPad's Safari only, console output:
jQuery.Deferred exception: Can't find variable: Kinvey
https://.html:22:15
l#https://code.jquery.com/jquery-3.3.1.min.js:2:29380
https://code.jquery.com/jquery-3.3.1.min.js:2:29678
Here's the code showing the error:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My App</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://da189i1jfloii.cloudfront.net/js/kinvey-html5-sdk-3.11.1.min.js"></script>
<script src="https://matthewcv.github.io/mobiledebug.js"></script>
</head>
<script>
$(document).ready(function() {
console.log("before");
// Init Kinvey
Kinvey.init({
appKey: '<yourAppKey>',
appSecret: '<yourAppSecret>'
});
console.log("after");
});
</script>
<body>
<div>
Show something
</div>
</body>
</html>
I'm working with the latest iOS as well as the latest Javascript packages.
I wrote several times into Kinvey's forum but nobody seems to care of. So I try it here in hope someone knows the solution.
Based on remotesynth's comment I was sure that something screwed up my iPhone. After a complete reset of the device I could make it working too.

Firefox this page has no sources

I'm working on a JavaScript game and it works as intended in Chrome and Safari. However, in Firefox, the page doesn't load any scripts, and the debugger is empty. I'm not seeing any errors at all. This is the entirety of the html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<canvas id="canvas"></canvas>
<script type="module" src="foo.js"></script>
<script type="module" src="bar.js"></script>
<script type="module" src="baz.js"></script>
<script type="module" src="qux.js"></script>
<script type="module" src="foobar.js"></script>
<script type="module" src="bazqux.js"></script>
</body>
</html>
UPDATE: Some added context for future readers: per Roko C. Buljan's answer, it turns out ES6 modules are not on by default in FireFox at the time of writing. That was the issue.
You're using module features not openly available in Firefox. To enable them you could go to about:config and enable them under dom.moduleScripts.enabled setting its Value to true
Meanwhile you could use a polyfill like this or use build tools that will compile your modules into a single ES5-backed production-ready file.
Some indepth readings:
https://html.spec.whatwg.org/multipage/webappapis.html#integration-with-the-javascript-module-system
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
https://jakearchibald.com/2017/es-modules-in-browsers/
https://medium.com/webpack/the-state-of-javascript-modules-4636d1774358

Why is javascript not executing on a web page when accessed via iOS Twitter browser?

I am completely stumped and I'm sure this was working before.
I have a simple web page with the word "hello" in a div which does two things onload:
1) alert "2"
2) change the text of the div to "bye"
All vanilla Javascript, no libraries.
This works fine on the Chrome, IE, FF, Safari (as you'd expect). If I hit a link in the iOS Twitter app (latest version) to this web page neither of those two things happen. It seems to me that the Javascript is not being executed at all but how can this be? Has anyone else experienced this?
UPDATE
In fact vanilla Javascript will work. The alert test was misleading - I believe thats been disabled which is why it won't work. JQuery will not work however - possibly to do with the $ reference conflicting.
UPDATE 2
The problem has moved on now - my initial assumptions were not entirely correct.
The following code for a web page works:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<style>
#test {
color:red;
}
</style>
<script>
window.onload = function () {
document.getElementById('test').innerHTML = 'vanilla javascript worked';
$("#test").text("Jquery worked");
}
</script>
</head>
<body>
<div id="test">
hello
</div>
</body>
</html>
The following code does not work. The path to my script is sound and works on normal browsers, but when in the iOS Twitter in-app browser it seems the local script will not load:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title></title>
<script src="~/Scripts/jquery-2.1.1.js" type="text/javascript"></script>
<style>
#test {
color:red;
}
</style>
<script>
window.onload = function () {
document.getElementById('test').innerHTML = 'vanilla javascript worked';
$("#test").text("Jquery worked");
}
</script>
</head>
<body>
<div id="test">
hello
</div>
</body>
</html>
I have tested the issue on accessing the webpage via Facebook which also works fine either way. The problem is with the Twitter browser only on iOS.
I have tried using an absolute path to my script which also does not work.
UPDATE
This issue is not on iPad. It is iPhone only. As it was working before fine I'd say this is a bug from the latest release of the iPhone Twitter app. Will wait for a fix from Twitter.
Turned out to be that I was re-writing all requests from Twitter to a pre-rendered html instance (brombone). So when it was looking for that file it was actually looking at the brombone server not mine. I took out the rewrite and its fine now.
Completely unrelated to what I was going on about but I solved it nonetheless and may be a reminder to those with similar problems to look outside of the box and check server setups etc...

iOS8 Safari's bug?

guys!
We are developing a realy simple web page.
But, touch events can't work in iOS8's Safari if we use iframe and web clip.
We don't know why.
Hear is our code.
And, we use web clip.
Even if we touch the div(id="hoge"), the alert doesn't appear.
Please help us...
・index.html
<!DOCTYPE html>
<html>
<body>
<div id="hoge">ABC</div>
<script>
document.getElementById("hoge").addEventListener('touchstart', function() { alert('Touch');});
</script>
</body>
</html>
・frame.html
<!DOCTYPE html>
<html>
<body>
<iframe src="./index.html"/>
</body>
</html>

Categories