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 07:34 Go to next message
Rk Moorthy is currently offline Rk Moorthy
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] Sun, 06 July 2014 23:03 Go to previous message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2253
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 WTP, IBM
Previous Topic:Eclipse Disorder
Next Topic:ScoreNinja
Goto Forum:
  


Current Time: Sun Aug 31 06:32:01 EDT 2014

Powered by FUDForum. Page generated in 0.08599 seconds