Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Java script function is not working(Java script function is not working)
Java script function is not working [message #1394498] Sat, 05 July 2014 11:34 Go to next message
Rk Moorthy is currently offline Rk MoorthyFriend
Messages: 1
Registered: July 2014
Junior Member
I am newbie of android development in eclipse.
Here i just created a web view, Created one html page and one java script function.
I can view the html controls in screen but the java script function(onclick) is not working..


My Web View:
------------
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//setTitle("Google Chart using HTML & JS");
WebView webView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);

_interface = new WebAppInterface(this);
webView.addJavascriptInterface(_interface, "WebAppInterface");
webView.loadUrl("file:///android_asset/index.html");
}

HTML(index.html):
-----------------
<html>
<head>
<script type="text/javascript" src="www/index.js"> </script>
<script type="text/javascript" src="www/webappinterface.js"> </script>
<link rel="stylesheet" type="text/css" href="./css/styles.css"/>

</head>
<body>
What's your name ?
<input id="name" value="" />
<button onclick="sayhello()">Say Hello</button>
</body>
</html>

JAVA SCRIPT FUNCTION(index.js):
-----------------------
function sayhello() { alert('Hi', + document.getElementById('name').value + '!'); }


Can anyone help me regarding this..





Re: Java script function is not working [message #1395527 is a reply to message #1394498] Mon, 07 July 2014 03:03 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

This question is highly specific to Android, not Eclipse.

https://www.eclipse.org/forums/index.php/t/225513/


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Eclipse Disorder
Next Topic:ScoreNinja
Goto Forum:
  


Current Time: Fri Apr 26 17:32:25 GMT 2024

Powered by FUDForum. Page generated in 0.08327 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top