Show ONLY JavaScript Disabled message [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to show a message that says "Please enable JavaScript to use this site" in the case that JavaScript is disabled, and nothing else to be displayed when JavaScript is disabled.Please do not reply ONLY about the <noscript> tag or code like this.

Use <noscript>, with a <style> rule inside the <noscript> that hides everything else using the body > *:not(noscript) selector:
<head>
<noscript>
<style>
body > *:not(noscript) {
display: none;
}
</style>
</noscript>
</head>
<body>
<noscript>
<p>Please enable JavaScript</p>
</noscript>
</body>

Related

Activate href by javascript [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I want to click on the first href element by javascript. But I have no idea how to reach website.com webpage with DOM. Can you tell me pls?
<!DOCTYPE html>
<html>
<body>
<td>hello</td>
<td>hi</td>
<script src=""></script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<td><a id="yourid" href="https://website.com" tabindex="-1">hello</a></td>
<td>hi</td>
<script>
function myFunction() {
document.getElementById("yourid").click();
}
</script>
</body>
</html>
give the first href an id and then paste this code in your script tag:

How to show simple json file data on html Page? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a json file which shows a number say "12925.09".
How can I show this number on my HTML page?
<html>
<title>HTML Tutorial</title>
<body>
Number =
</body>
</html>
Thanks
Here's one way. Run the script below, comments are within the code.
//Your possible (simple) json data
var numbers = {"number":10}
//Get number div by its id
var numberDiv = document.getElementById("numberDiv");
//Target number divs innerHTML and set it to the number value (10) in your numbers object
numberDiv.innerHTML = numbers.number;
<html>
<title>HTML Tutorial</title>
<body>
<div id="numberDiv"></div>
</body>
</html>

How to add <p> tags using javascript to a <div>? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want make a that auto scrolls and I want to be able to add paragraph tags to it using javascript.
Any help would be appreciated
var div = document.getElementsByTagName('div'),
p = document.createElement("p");
p.innerHTML = 'I am p Tag';
div[0].append(p);
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
</head>
<body>
<div> I am div Tag</div>
</body>
</html>
Depending on properties of your div like Id, name, class, u can also use
document.getElementById etc.
Using jQuery plugin for javascript, you can achieve this like that:
var myDiv = $("#IdOfYourDiv");
var paragraph = document.createElement("p");
paragraph.textContent = "something";
myDiv.append(paragraph);
but next time, pelase insert your html/javascript code, nobody have a crystal ball to know how you are writing your code to help you ;)

How to make a Go url bar in html+css [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Im a noob at js, and I would like to make a go bar like at the top of browsers in html and js. It will go to the url in the box when the button is pressed nothing more, nothing less. Heres about what i want:
In javascript you just have to add an event listener in the "Go" button.
Then when you click the button, you just have to redirect the url according to the text field value.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="text" id="field" />
<button id="myBtn">Go</button>
<script type="text/javascript">
document.getElementById("myBtn").addEventListener("click", function(){
var url = document.getElementById("field").value;
window.location.href = url;
// OR
window.open(url);
});
</script>
</body>
</html>
With this code, if you enter a value in the text field and click the button. The url will add your value at the end.
For example if you are testing on the url localhost/ and you enter "test", javascript will redirect you to localhost/test.
To redirect correctly you must write "http://" or "https://" at the beginning

How create Html button that run 2 linked js files? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
What do I need to do in order to execute the code inside my two external JS files when the button shown below is clicked?
<html>
<head>
<title>Vending Machine</title>
</head>
<body>
<script src="script.js"></script>
<script src="script2.js"></script>
<button type="button" onclick="">Press the Button</button>
</body>
</html>
Inside your javascript file there should be a function with name myFunction for example
<button onclick="myFunction()">Try it</button>
You should call the 2 functions from the files inside your click
<button type="button" onclick="function1(); function2();">Press the Button</button>

Categories

Resources