Html text box that will redirect [duplicate] - html

This question already has an answer here:
Javascript URL Redirection based on a text box
(1 answer)
Closed 5 years ago.
m pretty terrible at web design and i just wanted to know how to make a text box that will redirect after putting in a certain phrase and pressing enter.
Thanks for help

This should work:
<form><input id="myInput" onblur="myFunction()" /></form>
<script>
function myFunction() {
if(document.getElementById('myInput').value == 'test') {
window.location.href='http://www.google.com';
}
}
</script>
See: https://codepen.io/anon/pen/gxLGgE

Related

How to create a button on google slide that will trigger the insert image option? [duplicate]

This question already has answers here:
How to call a function via a link/button on a Google Slide?
(2 answers)
Closed 2 years ago.
I would like to know is there any way to add a button to google slide that will directly trigger the insert image option, so that user can directly insert the image by only clicking the button without going to the insert option in the top, is it possible to use script functionality ? then how ?.Please see this snapshot
https://developers.google.com/apps-script/guides/menus
That page explains how you can add UI elements. You can build a HTML and call app script functions from the HTML
<html>
<head>
<script>
function clickFunc(){
google.script.run.myFunctionNew();
}
</script>
</head>
<body>
<button onclick="clickFunc()">ADD IMAGE</button>
</body>
</html>
In your code.gs you can define myFunctionNew function to add image

Refresh the page after clicking on the area [duplicate]

This question already has answers here:
Button that refreshes the page on click
(18 answers)
Closed 3 years ago.
I want to refresh my website after clicking on a specific area (container)
Any ideas?
THANKS!
You can use Location.reload() API interface (https://developer.mozilla.org/ru/docs/Web/API/Location/reload)
So the answer could look as follows:
document.querySelector('you-area-selector-here').addEventListener((click) => {
window.location.reload(true);
})
true flag is required to be sure the page was reloaded from server, not from cache.
It is not a good practice to mix js with HTML.
I would do it this way:
let refreshPage = document.querySelector('#div1').addEventListener('click', => {
location.reload();
})
note: you must give id or class to the element you are trying to select in this function.
There are other way of doing it i.e = document.querySelectorAll, getElementById, getElementByClassName, getElementByTagName.

HTML: Button that links to a .html file [duplicate]

This question already has answers here:
How do I create an HTML button that acts like a link?
(35 answers)
Closed 7 years ago.
I'm trying to make a button that links to a file (spaceRace.html), but I don't know how I would get the button to link to the file.
Please tell me what I should put in the button code.
<button type="button" onclick="">1 Player Mode</button>
Any help would be highly appreciated,
<input type = "button" style = "color:red; height:100px;width:125px; font-size:10px;font-family:'COMIC SANS MS' " value = "1 Player Mode"/>

Is it possible to change the content HTML5 alert messages? [duplicate]

This question already has answers here:
How to set custom validation messages for HTML forms?
(17 answers)
Set custom HTML5 required field validation message
(12 answers)
Closed 8 years ago.
Is it possible to control HTML5 alert messages? when adding 'required' to an input field.
because I want it to be specific and I don't want it's language to depend on the browsers.
<input id="answer" required>
You can use customValidity
$(function(){
var elements = document.getElementsByTagName("input");
for (var i = 0; i < elements.length; i++) {
elements[i].oninvalid = function(e) {
e.target.setCustomValidity("This can't be left blank!");
};
}
});
I think that will work on at least Chrome and FF, I'm not sure about other browsers
Thank you guys for the help,
When I asked at first I didn't think it's even possible, but after your answers I googled and found this amazing tutorial:
http://blog.thomaslebrun.net/2011/11/html-5-how-to-customize-the-error-message-for-a-required-field/#.UsNN1BYrh2M
Yes:
<input required title="Enter something OR ELSE." />
The title attribute will be used to notify the user of a problem.

How do I check all checkboxes on an HTML page with one click? [duplicate]

This question already has answers here:
Closed 14 years ago.
I am html page with 5 checkboxes
My requirement is to have one morecheckboxes "Select All" which is used to select all 5 checkboxes.
Thanks in advance
Closed as exact duplicate of this question.
If you're looking for javascript that will check your 5 checkboxes when the 6th is clicked, something like this should work:
function CheckAll(value){
document.getElementByID("CheckBox1").checked = value;
document.getElementByID("CheckBox2").checked = value;
document.getElementByID("CheckBox3").checked = value;
document.getElementByID("CheckBox4").checked = value;
document.getElementByID("CheckBox5").checked = value;
}
<input type="checkbox" id="CheckBox6" onclick="CheckAll(this.checked)"><label>Check All</label>
In "pure" HTML, you can't, though you can modify your server-side code to correctly interpret that checkbox as meaning "act as though all the others were checked".
It's fairly easy using Javascript. Create a method that is fired when the "select all" checkbox is checked, and then find the other checkboxes by ID and mark them as checked. It's unclear what you should do if the "select all" checkbox is unchecked though, so perhaps it should just be a link.
You can't do this in just HTML, but should be fairly simple with javascript.
Personally I would use jQuery like this: http://abeautifulsite.net/notebook/50
This is a job for jQuery. Spend some time today and learn about it if you can. It's awesome for just this sort of task.