I just created a new widget by following a tutorial. I created a zip containing all files and renamed it to HelloWorld.wgt instead of HelloWorld.zip. I sent it to my samsung star/corby via data cable, but when I try to open the wgt file on my phone it says it can't open it, because it doesn't know the filetype. Is there a way to install widgets on a Samsung Star without using a webserver?
Thanks,
Rohit desai
Just create an HTML file like this:
<html>
<head>
<title>Hello</title>
</head>
<body>
Install widget
</body>
</html>
Put the HTML file in the same folder with your widget and open the file. Click on Install widget and you are done.
P.S.: If you don't want to modify the HTML file for every widget you want to install use this code:
<html>
<head>
<title>Hello</title>
<script>
function download()
{
var widgetName = document.getElementById("widgetName");
location.href = widgetName.value + ".wgt";
}
</script>
</head>
<body>
<input type="text" name="widgetName" id="widgetName" />
<input type="button" value="Install widget" onclick = "download()" />
</body>
</html>
Related
test.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>This is test Page for Learn JS</title>
<script type="text/javascript" src="/learn/test.js"></script>
</head>
<body>
<input type="button" value="Time" onclick="daytime()">
<p id="now"></p>
</body>
</html>
This is test.js
function daytime() {
document.getElementById("now").innerHTML=Date();
}
why click button,is nothing to do.
but insert js code to html,it's working
maybe you can check your js and html folder location.
can try to put your js and html in a same folder, and update your script src to "./test.js"
You must use the script tag and pass the address of your "test.js" file to the src attribute. Assuming your test.js is in the same directory as your test.html file, you can use this to link them up.
<script src = "./test.js"></script>
Place the script tag just before the closing of body tag, this helps in loading the body content first and then the JavaScript, making the user experience better.
looks like the issue is how you include the script file.
src="/learn/test.js"
If the folder "learn" is in the same folder as the HTML file, try removing the "/"
src="learn/test.js"
I am trying to make a very simple thing work:
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script src="js/test.js" type="text/js"></script>
<button onclick="test()" type="submit">Test</button>
</body>
</html>
With js/test.js being found by the browser and containing:
function test() {
alert("test");
}
When opening the page and clicking the button, nothing happens and I can see in the console:
Uncaught ReferenceError: test is not defined
at HTMLButtonElement.onclick (test:7)
I have tried to move the script import above or under the button, or in the header.
I have tried to use "window.setlocale = function" in my js file.
I have tried to put nothing in the test method.
I checked for errors with JSLint (there is no error).
When I check the source, I can see the js file and the browser opens it when I click on it.
The only way I can get the Javascript to work is to write it inline...
Maybe the issue is with my environment?
In order to run this, I use an Apache server, and it is configured to serve this on localhost:8077. I works fine so far.
I use Laravel 7.10, PHP 7.4... working fine. To run this I created a simple route, that shows the view (a simple index.blade.php) with the HTML content copy/pasted above. It displays fine on "http://localhost:8077/test", no problem.
I also tried to use the laravel notation
<script src="{{ asset('js/test.js') }}" type="text/js"></script>
but it gives the same result.
I also have the PHP debugbar (a Laravel plugin) active, and it does not show any error. The view is properly loaded and displayed.
Also, I use PHPStorm, and it does not detect any issue.
It's been 2 days and I cannot makes this seemingly extremely basic thing to work, please help me m(_ _)m
Your script type is wrong. Use application/javascript in your script element to make your javascript work - or better yet, remove the type attribute and let browsers auto-detect the type:
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script src="js/test.js" type="application/javascript"></script>
<button onclick="test()" type="submit">Test</button>
</body>
</html>
Without type attribute:
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script src="js/test.js"></script>
<button onclick="test()" type="submit">Test</button>
</body>
</html>
you can try to add script tag to header tag. like this
<head>
<script type="text/javascript" src="path/to/script.js"></script>
<!--other script and also external css included over here-->
</head>
Try removing the function name in js/test.js
function() {
alert("test");
}
Please add the js file as a reference in the header section of your core file. External referencing.
Code on webpageThe button doesn't workSo, I am fairly new to JavaScript and have been looking at tutorials for the language. I downloaded the Atom IDE and began following a video and used the same code as the video to make a web page with a button that reveals a message when clicked. However when I click the button nothing happens, and when I hit inspect element.
It gives me the following error: Failed to load resource: net::ERR_FILE_NOT_FOUND
It appears as though the HTML file is not working with the .js file. However they are in the same directory.
Here's the updated code (still the same error):
<DOCTYPE! html>
<html>
<head>
</head>
<body>
<button onclick="revealMessage()">Click me!</button>
<p id="hiddenMessage" style="display:none">Filosofem</p>
</body>
<script>
function revealMessage() {
document.getElementById("hiddenMessage").style.display = 'block';
}
</script>
</html>
Perhaps, it is the file directory. When you declared <script src="js/script.js"></script>, that means that your script.js file, must be located in a subfolder called "js".
If you want your to be within your file, then you can do
<DOCTYPE! html>
<html>
<head>
</head>
<body>
<button onclick="revealMessage()">Click me!</button>
<p id="hiddenMessage" style="display:none">Filosofem</p>
</body>
<script>
function revealMessage() {
document.getElementById("hiddenMessage").style.display = 'block';
}
</script>
</html>
Finally, you should try resaving the code through atom, and make sure your code is the right version of your code.
By using an external stylesheet you need to make sure your CSS file is saved as said above but with <script scr="filename.js">/script> I still haven't found a way other than having your code internal which is completely fine unless you're making a world wide website then it would be easy to hack.
I'm trying to make a simple page with JS which generates Batch Scrips based on user input.
This is the prototype code and works fine with Chrome, but clicking on link with Firefox downloads the file as .txt (e.g.: file.bat.txt) and IE is completey unresponsive to the link
Where am i going wrong?
Any issues with "data:text/plain;base64,"?
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
</head>
<body>
click here
<script>
var bat_source = "#echo off\necho Hello world\npause";
document.querySelector("a").href = 'data:text/plain;base64,' + btoa(bat_source);
</script>
</body>
</html>
I am developing a test app in PhoneGap build. Currently I'm trying to redirect to a page when the app loads. But when I tried to do that, it is not redirecting, instead staying in index.html page only. I am using TestObject for testing the app.
index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" charset="utf-8">
function init() {
document.addEventListener("deviceready", onDeviceReady, true);
}
function onDeviceReady() {
alert("Device is ready");
}
</script>
</head>
<body onload="init();">
<input type="button" onclick="location.href='http://google.com';" value="Go to Google" />
Hai welcome to my app
</body>
</html>
config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.mydomain.mobileApp"
versionCode = "1"
version = "1.0.0" >
<!-- versionCode is Android only -->
<!-- version is in major.minor.patch format -->
<name>My App</name>
<description>
An example for phonegap build app which wont show up in the playstore.
</description>
<author href="https://YourWebsite.com" email="yourEmail#goesHere.com">
Name Of The Author
</author>
</widget>
When I test this in browser, on clicking button it will redirect to http://google.com. But when I upload the apk (build from phonebuild) and upload to TestObject, button is coming. But on clicking it nothing happens. When I test the app,I'm getting like this.
Can anyone help me to find the issue. Thanks in advance.
You need to include cordova in your application
and try this one as well
document.addEventListener("deviceready", function(){
alert("Device ready Fire");
},true);
Include phonegap.js in head section of HTML file and do not make the click event handler inline. Register the event handler in script part. And also make sure you have included whitelist plugin. Try following code:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript">
function myFun(){
document.getElementById("myBtn").addEventListener("click", function(){
location.href='http://google.com';
});
}
</script>
</head>
<body onload="myFun()">
<button id="myBtn">Go to Google</button>
Hai welcome to my app
</body>
</html>