Issue with Inject JS code to webview inside chrome OS app - javascript

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.

Related

external js from keenthemes metronic theme not working in angular

hey guys so I am using metronic theme and I made an angular version of demo3 HTML version
and everything looks fine except
if I import external js like this
<!doctype html>
<html lang="fa" direction="rtl" dir="rtl" style="direction: rtl">
<head>
<meta charset="utf-8" />
<base href="/">
<script src="assets/plugins/global/plugins.bundle.js" type="application/javascript"></script>
<script src="assets/plugins/custom/prismjs/prismjs.bundle.js" type="application/javascript"></script>
<script src="assets/js/scripts.bundle.js" type="application/javascript"></script>
<script src="assets/plugins/custom/fullcalendar/fullcalendar.bundle.js" type="application/javascript"></script>
<script src="assets/js/pages/widgets.js" type="application/javascript"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body kt-root id="kt_body" class="header-mobile-fixed subheader-enabled aside-enabled aside-fixed aside-secondary-enabled page-loading">
</body>
</html>
I don't have any error but toggle buttons not working
and if I added like this to angualr.json file
"scripts": [
"src/assets/plugins/global/plugins.bundle.js",
"src/assets/plugins/custom/prismjs/prismjs.bundle.js",
"src/assets/js/scripts.bundle.js",
"src/assets/plugins/custom/fullcalendar/fullcalendar.bundle.js",
"src/assets/js/pages/widgets.js"
]
when I serve the project I get this error
add
import 'core-js';
in the polyfills.ts file before the zone
and if you have or imported es6-shim just remove that
and I don't know why your external js not working that's the other problem

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>

LAMP: browsers not supports javascript in ubuntu

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/

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

Combining and minifying JS and CSS in ASP.NET MVC

I created default ASP.NET MVC 3 web application. Then I added three css and three js files to \Views\Shared_Layout.cshtml view:
<!DOCTYPE html>
<html>
<head>
<title>#ViewBag.Title</title>
<link href="#Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<link href="#Url.Content("~/Content/StyleSheet1.css")" rel="stylesheet" type="text/css" />
<link href="#Url.Content("~/Content/StyleSheet2.css")" rel="stylesheet" type="text/css" />
<script src="#Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/JScript1.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/JScript2.js")" type="text/javascript"></script>
</head>
<body>
<div class="page">
<div id="header">
....
when I run the application, I html code is
<!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
<link href="/Content/Site.css" rel="stylesheet" type="text/css" />
<link href="/Content/StyleSheet1.css" rel="stylesheet" type="text/css" />
<link href="/Content/StyleSheet2.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="/Scripts/JScript1.js" type="text/javascript"></script>
<script src="/Scripts/JScript2.js" type="text/javascript"></script>
</head>
<body>
<div class="page">
Is it possible to have a handler in MVC to change my output html to like:
<!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
<script src="js.axd=/Scripts/jquery-1.5.1.min.js,/Scripts/JScript1.js,/Scripts/JScript2.js" type="text/javascript"></script>
<link href="css.axd=/Content/Site.css,/Content/StyleSheet1.css,/Content/StyleSheet2.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="page">
So the link js.axd=/Scripts/jquery-1.5.1.min.js,/Scripts/JScript1.js,/Scripts/JScript2.js
will return content of all these js files to the browser, and link css.axd=/Content/Site.css,/Content/StyleSheet1.css,/Content/StyleSheet2.css will return content of all css files.
I did something before in ASP.NET by IHttpHandler, but can't figure out how to do that in MVC, since I'm just starter in MVC.
Any help and code samples will appreciate.
Thank you!
You can use bundle and minification nuget package. Bundling and Minification
At the NuGet console type: "Install-Package Microsoft.AspNet.Web.Optimization"
Example here:
Using Web Optimization with MVC 3
I use cassette in my own projects. Also, this list here contains top 20 in Nuget.

Categories