I want to enable a Google reCAPTCHA if F5 is pressed.
I have this code at the moment:
<html>
<head>
<title>HELLO</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script type="text/javascript">
document.onkeydown = fkey;
document.onkeypress = fkey
document.onkeyup = fkey;
var wasPressed = false;
function fkey(e){
e = e || window.event;
if( wasPressed ) return;
if (e.keyCode == 116) {
alert("f5 pressed");
// here the Google reCAPTCHA code have to come.
wasPressed = true;
}else {
alert("Window closed");
}
}
</script>
</head>
<body>
<p>If you press F5 you will get a Google reCAPTCHA</p>
</body>
</html>
<div class="g-recaptcha" data-sitekey="6LehRSETAAAAAIl2C3nRFguErdFn02smPN_vtPro"></div>
This is the code to show up the Google reCAPTCHA.
I hope someone can help me, so I can go further. Thanks :D
<html>
<head>
<title>HELLO</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script type="text/javascript">
document.onkeydown = fkey;
document.onkeypress = fkey
document.onkeyup = fkey;
var wasPressed = false;
function fkey(e){
e = e || window.event;
if( wasPressed ) return;
if (e.keyCode == 116) {
// here the Google reCAPTCHA code have to come.
$('.g-recaptcha').show();
e.preventDefault();
wasPressed = true;
}else {
alert("Window closed");
}
}
</script>
</head>
<body>
<p>If you press F5 you will get a Google reCAPTCHA</p>
<div class="g-recaptcha" data-sitekey="6LehRSETAAAAAIl2C3nRFguErdFn02smPN_vtPro" style="display:none;"></div>
</body>
</html>
Related
I'm trying to display play or pause button when a user clicks on it. I know I can actually compare those links but I think using a variable would be easier to see?
Thanks.
`
<!DOCTYPE html>
<html>
<head>
<title>ch6</title>
</head>
<body>
<h1>List</h1>
<h2>audio note</h2>
<p>Enter note name</p>
<input type="text" >
<br>
<img id="pic" onclick="click()" src="http://www.clker.com/cliparts/d/b/c/f/13652249372108434179Record%20Button%20Microphone.svg.hi.png" alt="record" style="width:50px;height:60px;">
<script type="text/javascript">
function click(){
var butt = true;
if(butt === true)
{
document.getElementById("pic").src = "https://www.shareicon.net/download/2017/02/07/878546_media_512x512.png";
butt = false;
}
else
{
document.getElementById("pic").src = "http://www.clker.com/cliparts/d/b/c/f/13652249372108434179Record%20Button%20Microphone.svg.hi.png";
butt = true;
}
}
</script>
</body>
</html>
`
I hope to click to change the image.
The image doesn't change when I click it.
Seems like HTML/JS doesn't allow a function named click to be set to onclick. Please change
function click(){
to
function clickk(){
and
<img id="pic" onclick="click()"
to
<img id="pic" onclick="clickk()"
Also, move your var butt = true; outside the function.
Full example below:
<!DOCTYPE html>
<html>
<head>
<title>ch6</title>
</head>
<body>
<h1>List</h1>
<h2>audio note</h2>
<p>Enter note name</p>
<input type="text">
<br>
<img id="pic" onclick="clickk()" src="http://www.clker.com/cliparts/d/b/c/f/13652249372108434179Record%20Button%20Microphone.svg.hi.png" alt="record" style="width:50px;height:60px;">
<script type="text/javascript">
var butt = true;
function clickk() {
if (butt === true) {
document.getElementById("pic").src = "https://www.shareicon.net/download/2017/02/07/878546_media_512x512.png";
butt = false;
} else {
document.getElementById("pic").src = "http://www.clker.com/cliparts/d/b/c/f/13652249372108434179Record%20Button%20Microphone.svg.hi.png";
butt = true;
}
}
</script>
</body>
</html>
You need to take the variable initialization outside of the function itself
<script type="text/javascript">
var butt = true;
function click(){
if(butt === true)
{
document.getElementById("pic").src = "https://www.shareicon.net/download/2017/02/07/878546_media_512x512.png";
butt = false;
}
else
{
document.getElementById("pic").src = "http://www.clker.com/cliparts/d/b/c/f/13652249372108434179Record%20Button%20Microphone.svg.hi.png";
butt = true;
}
}
</script>
Try use this code:
<img id="pic" src="http://www.clker.com/cliparts/d/b/c/f/13652249372108434179Record%20Button%20Microphone.svg.hi.png" alt="record" style="width:50px;height:60px;">
<script type="text/javascript">
var butt = true;
var img = document.getElementById('pic');
img.addEventListener('click', click);
function click(e){
if(butt === true)
{
e.target.src = "https://www.shareicon.net/download/2017/02/07/878546_media_512x512.png";
butt = false;
}
else
{
e.target.src = "http://www.clker.com/cliparts/d/b/c/f/13652249372108434179Record%20Button%20Microphone.svg.hi.png";
butt = true;
}
}
Declare the variable outside the click function::
var butt = true;
function click(){
}
now work same in that function
'use strict';
function phone() {
if( navigator.userAgent.match(/Android/gi)
|| navigator.userAgent.match(/webOS/gi)
|| navigator.userAgent.match(/iPhone/gi)
|| navigator.userAgent.match(/iPad/gi)
|| navigator.userAgent.match(/iPod/gi)
|| navigator.userAgent.match(/BlackBerry/gi)
|| navigator.userAgent.match(/Windows Phone/gi)
){
return true;
}
else {
return false;
}
}
<!doctype html>
<html>
<head>
<link rel=stylesheet id="style" href='style.css'/>
</head>
<body>
<script src="phone.js"></script>
<script>
phone();
</script>
</body>
</html>
The external function won't run when the page opens why is that? I even tried doing onload but nothing happened. When the page opens it should print in the console either true or false but absolutely nothing is printed.
You are not actually printing the result. You need to change to this:
<script>
console.log( "Is phone: " + phone() );
</script>
When tested locally the example below works perfectly. It cycles through different jsmovermaps on mouse press, but when I test this on the server it doesn't update the jsmovermap relevant to cursor press. I have uploaded the maps correctly. Any help would be appreciated.
Many thanks!!!
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Ireland Map</title>
<link type="text/css" rel="stylesheet" href="jquery.qtip.css" />
<link rel="stylesheet" type="text/css" href="style2.css">
</head>
<body>
<div class="map" id="map">
</div>
<script src="jquery-2.1.1.min.js"></script>
<script src="raphael-min.js"></script>
<script src="jquery.qtip.js"></script>
<script src="jsmovermap1.js" id="s1"></script>
<script>
x=1;
//alert(x);
document.addEventListener('keydown', function (evt) {
if (evt.keyCode === 38) {
//alert('The "UP" key is being held down...?');
x=x+1;
//alert(x);
//script.src = "jsmovermap"+(x)+".js";
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "jsmovermap"+(x)+".js";;
s.innerHTML = null;
s.id = "map";
document.getElementById("map").innerHTML = "";
document.getElementById("map").appendChild(s);
//alert(s.src);
}
if (evt.keyCode === 40) {
//alert('The "DOWN" key is being held down...?');
x=x-1;
if(x<1){
x=1}
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "jsmovermap"+(x)+".js";;
s.innerHTML = null;
s.id = "map";
document.getElementById("map").innerHTML = "";
document.getElementById("map").appendChild(s);
//alert(x);
}
});
</script>
</body>
</html>
UPDATE!
This is what the console is spitting out after a number of cursor presses.
Resource interpreted as Script but transferred with MIME type text/html: "http://jeremiahambrose.com/maptest/Test/jsmovermap23.js".
Following is the script
<script type="text/javascript">
function DoFullScreen() {
var isInFullScreen = (document.fullScreenElement && document.fullScreenElement !== null) || // alternative standard method
(document.mozFullScreen || document.webkitIsFullScreen);
var docElm = document.documentElement;
if (!isInFullScreen) {
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
}
else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
//alert("Mozilla entering fullscreen!");
}
else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
alert("Webkit entering fullscreen!");
}
}
}
</script>
HTML
<body onload="DoFullScreen()">
<form id="form1" runat="server" >
<div id="div1">
<input id="bt1" type="button" value="button" />
Hello
</div>
</form>
</body>
I have tried
$(window).load
$(document).ready(function(){ $("#bt1").load
-- it's not possible force a fullscreen if it's not triggered by a user action
-- look at this
full-screen browser window on load document
on ready call your function
$(document).ready(function(){
DoFullScreen();
}
You can do it using pure javascript only like this:
<script type="text/javascript">
window.onload = function () {
// YOUR CODE STUFF
}
</script>
Could you please post the HTML source code of this web page:
http://www.xuanyinwen.com/test3.html
I just cannot figure out how to retrieve it..
You can use wget or switch off JavaScript.
P.S.: The magic word is "wen".
Just use "View source" option from tool menu in browser.
<head>
<script language="JavaScript">
var password;
var pass1="wen";
password = prompt('Whats The Magic Word?',' ');
if (password === pass1)
alert('That Is Correct!');
else
window.location="SITE-LINK";
</script>
</head>
<body onLoad="ImageBook()">
TEST
</body>
</html>
"Right-Click + Save Link/Target As..." can be helpful sometimes :) There are several methods of doing this.
<head>
<script language="JavaScript">
var password;
var pass1="wen";
password = prompt('Whats The Magic Word?',' ');
if (password === pass1)
alert('That Is Correct!');
else
window.location="SITE-LINK";
</script>
</head>
<body onLoad="ImageBook()">
TEST
</body>
</html>
Either disable JavaScript on your browser, or use some kind of command line tool (e.g curl).
<head>
<script language="JavaScript">
var password;
var pass1="wen";
password = prompt('Whats The Magic Word?',' ');
if (password === pass1)
alert('That Is Correct!');
else
window.location="SITE-LINK";
</script>
</head>
<body onLoad="ImageBook()">
TEST
</body>
</html>
Use firebug in firefox and select the script.
<head><script language="JavaScript">var password;var pass1="wen";password = prompt('Whats The Magic Word?',' ');if (password === pass1) alert('That Is Correct!');else window.location="SITE-LINK";</script></head> <body onLoad="ImageBook()">TEST </body></html>
Type in keyboard
Ctrl + U in windows 10