LAMP: browsers not supports javascript in ubuntu - javascript

I am using ubuntu 15.04 in vmware 12, i created a test project in /var/www/html, all browsers(FF,Chrome,etc) supports css but not supports javascript code, i checked with internal and external javascript also but no use.
My sample code : /var/www/html/firstpro/index.php
<!doctype html>
<html>
<head>
<title>index</title>
<link href="css/style.css" rel="stylesheet">
<!--<script src="script/script.js" type="text/javascript"></script>-->
<script>
function test(){
alert('hi');
}
</script>
</head>
<body>
<span onclick="test();">test js</span>
</body>
</html>

Check out the corrected code if you are looking for JS alert:
<a onclick="test();">test js</a> This will by default reload the page. You need to update it to test js
<!doctype html>
<html>
<head>
<title>index</title>
<link href="css/style.css" rel="stylesheet">
<!--<script src="script/script.js" type="text/javascript"></script>-->
<script>
function test(){
alert('hi');
}
</script>
</head>
<body>
test js
</body>
</html>
Check this JSFiddle https://jsfiddle.net/0ba7cfwn/

Related

Issue with Inject JS code to webview inside chrome OS app

I Created a Chrome OS APP to be a webview of my website, but I need to inject some JS codes to send some information to my server.
here the codes
exported_app_view.html
<!DOCTYPE html>
<html class="trim full">
<head>
<link rel="stylesheet" href="css/foam.css" />
<link rel="stylesheet" href="css/cab.css" />
<link rel="stylesheet" type="text/css" href="application.css">
</head>
<script src="application.js">
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js">
</script>
<body class="trim full">
<foam id="kiosk" model="AppConfig" view="KioskView">
<webview id="map" src="http://link.com/"> </webview>
</foam>
</body>
</html>
application.js
setInterval(function(){
core.appver = "1";
}, 2000);
it is not working like this, but If inserted code like window.close(); it works well.

Where to place line of code in html for ReactDOM.render?

I have the following code which is in a saved format of .html (index.html).
I am learning React right now and when I execute this html file in the browser, nothing happens.
I am wondering where the two lines of code are suppose to go or how to call them (execute the rendering).
Where would I find the files in ./lib if I am using a mac?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Introduction | Learning React</title>
<link rel="stylesheet" href="lib/style.css" />
</head>
<body>
<section id="entry-point"></section>
<!-- Wifi might be spotty, so we've downloaded these to `./lib` -->
<script src="lib/react.js"></script>
<script src="lib/react-dom.js"></script>
<script type="text/javascript">
// Intentionally blank. Your walk-through code will go here
var hello = React.createElement('p', null, 'Hello, World!');
// Checkout what this does by opening your HTML file in the browser
ReactDOM.render(hello, document.getElementById('entry-point'));
</script>
</body>
</html>
It works as long as you include the proper libraries:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Introduction | Learning React</title>
<link rel="stylesheet" href="lib/style.css" />
</head>
<body>
<section id="entry-point"></section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<script type="text/javascript">
// Intentionally blank. Your walk-through code will go here
var hello = React.createElement('p', null, 'Hello, World!');
// Checkout what this does by opening your HTML file in the browser
ReactDOM.render(hello, document.getElementById('entry-point'));
</script>
</body>
</html>
Using the correct setup (JSX compiler, e.g. Babel), you could simplify the above createElement to:
ReactDOM.render(
<p>Hello, World!</p>,
document.getElementById('entry-point')
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="entry-point"></div>
If you don't want to use packet managers you can include React with CDNs.
For development:
<script src="https://unpkg.com/react#15/dist/react.js"></script>
<script src="https://unpkg.com/react-dom#15/dist/react-dom.js"></script>
For production (minified):
<script src="https://unpkg.com/react#15/dist/react.min.js"></script>
<script src="https://unpkg.com/react-dom#15/dist/react-dom.min.js"></script>

html, javascript code works perfectly on my pc browser but not on my windows phone app

I'm trying to make a windows phone 8.1 app that send a get request using html5 css and javascript. the only problem is the my code works on my browser but when I build the app using visual studio the get request is sent only the first time. I have no clue why this happens.
The code for the page is this :
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script>
$(document).ready(function()
{
$("button").click(function()
{
$.get("http://192.168.1.100/gpio/0")
});
} );
</script>
</head>
<body>
<button>Send GET request </button>
</body>
</html>
The code that I use for the app is the same with just a few changes :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>App1</title>
<!-- WinJS references -->
<link href="//Microsoft.WinJS.2.0/css/ui-dark.css" rel="stylesheet" />
<script src="//Microsoft.WinJS.2.0/js/base.js"></script>
<script src="//Microsoft.WinJS.2.0/js/ui.js"></script>
<!-- App1 references -->
<link href="/css/default.css" rel="stylesheet" />
<script src="/js/default.js"></script>
<script src="/js/jquery-1.12.1.js"></script>
<script>
$(document).ready(function () {
$("button").click(function () {
$.get("http://192.168.1.100/gpio/0")
});
});
</script>
</head>
<body>
<button>Send GET request</button>
</body>
</html>

javascript alert() function not working in UWP app

I used some little basic javascript code and used it to make a simple UWP app, the alert function in the code works when i run the file in the browser, but it doesnt work when i try it in UWP app. below is the code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>App6</title>
<!-- WinJS references -->
<link href="WinJS/css/ui-dark.css" rel="stylesheet" />
<script src="WinJS/js/base.js"></script>
<script src="WinJS/js/ui.js"></script>
<!-- App6 references -->
<link href="/css/default.css" rel="stylesheet" />
<script src="/js/default.js"></script>
</head>
<body class="win-type-body" onload="alert('oh yeah');">
</body>
</html>
The alert function is not supported in UWP app context. You have to use
var dialog = new Windows.UI.Popups.MessageDialog("Hello");
dialog.showAsync();
https://msdn.microsoft.com/library/windows/apps/br208674?cs-save-lang=1&cs-lang=javascript#code-snippet-1

AngularJS: "Hello Word" not working

I've had a look at similar answers but haven't seen an answer to this.
My directory structure is simply:
Test
|---index.html
|---bootstrap.min.css
|---angular.min.js
|---app.js
My code:
<!doctype HTML>
<html ng-app="store">
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
</head>
<body>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="app.js"></script>
<p>I am {{4 + 6}}</p>
<p>{{"Hello" + " you"}}</p>
</body>
</html>
Sadly, running this in the browser (file:///Users/Will/Projects/angular/demo/index.html), it doesn't work. Is this because it's local?
Consider that the following works when loaded directly from the filesystem (and not a webserver):
<!doctype HTML>
<html ng-app>
<head>
<title>Test</title>
</head>
<body>
<script type="text/javascript" src="angular.min.js"></script>
<p>I am {{4 + 6}}</p>
<p>{{"Hello" + " you"}}</p>
</body>
</html>
Note that I have changed "ng-app='store'" to "ng-app", so that angular is not trying to load the 'store' module.
This shows that angular, on its own, is doing its thing correctly. So the issue is somewhere within the store module. As suggested in the comments, check your browser console for error messages, and troubleshoot those.

Categories