I'm trying to make a window pops up and then moves continuously using setInterval(). It pops up but it doesn't move.
I'm using all the html files in the same directory.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>popup</title>
</head>
<body>
<input type="button" name="" value="new window" onclick="newWin();">
<input type="button" name="" value="stop window" onclick="stopWin()">
<script type="text/javascript">
var win1;
var interv;
function moveWin(){
win1.moveBy(100, 100);
win1.focus();
}
function newWin(){
win1 = window.open('new.html', 'win1', 'width=200, height=150');
win1.focus();
interv = setInterval(moveWin, 1000);
}
function stopWin(){
clearInterval(interv);
}
</script>
</body>
</html>
Related
Why this code is not working in FB App Messenger Browser (Webview).
Parent Window:
<html>
<head>
<script language="Javascript">
function showFBWindow(){
url = "allowfbchild.html"
newwindow=window.open(url,'name','height=200,width=150');
if (window.focus) {newwindow.focus()}
}
</script>
</head>
<body>
<input type="button" OnClick="showFBWindow()" value="Open FB" />
</body>
</html>
Child Window(allowfbchild.html) :
<html>
<head>
<script language="Javascript">
function redirectToFB(){
window.opener.location.href="http://wwww.facebook.com";
self.close();
}
</script>
</head>
<body>
Allow the user to view FB
<br/>Are you sure?
<input type="button" value="Ok" OnClick="redirectToFB()" />
</body>
</html>
When clicking on redirectToFB() button. Its not working as per coded.
I was asked to develop a web page without a mouse.
The keyboard cursor must be in the input area(example: <input id="input-label" type="text">) immediately when the page is changed.
I tried,
document.querySelector("#input-area").focus();
and
document.querySelector("#input-area").select();
It works with buttons, but does not work in DOMContentLoaded.
document.addEventListener("DOMContentLoaded", function(){
document.querySelector("#input-area").select();
});
How can I solve it?
try this, call it when dom is ready
$(document).ready(function () {
$("#input-area").focus();
});
OR
<input id="input-area" autofocus="autofocus" />
OR
$(function() {
$("#input-area").focus();
});
Try this code:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.js"></script>
<script>
$(document).ready(function(){
$('#myAnchor').click(function() {
$('#mustfocus').focus();
});
});
</script>
</head>
<body>
<input type="button" id="myAnchor" value="Get focus">
<input type="text" id="mustfocus"/>
</body>
</html>
How about this one which triggers only during DOM is ready:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.js"></script>
<script>
$(document).ready(function(){
$('#mustfocus').focus();
});
</script>
</head>
<body>
<input type="button" id="myAnchor" value="Get focus">
<input type="text" id="mustfocus"/>
</body>
</html>
I have two links in a corporate intranet site, built in Sharepoint, that I need to link to Firefox. The links are to an external site that does not work in I.E. However, the corporate browser is I.E., so that's what most people see.
I found the below code that works when I have one link. How do I get it to work for two links?
Here's the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>HTA Test</title>
<hta:application applicationname="HTA Test" scroll="yes" singleinstance="yes">
<script type="text/javascript">
function openURL()
{
var shell = new ActiveXObject("WScript.Shell");
shell.run("http://www.google.com");
}
</script>
</head>
<body>
<input type="button" onclick="openURL()" value="Open Google">
</body>
</html>
You can modify your script to something like:
<script type="text/javascript">
function openURL(url)
{
var shell = new ActiveXObject("WScript.Shell");
shell.run(url);
}
</script>
</head>
<body>
<input type="button" onclick="openURL('http://www.google.com')" value="Open Google">
<input type="button" onclick="openURL('http://www.yahoo.com')" value="Open Yahoo">
I want display the form data to new tab using JavaScript only. This is not proceeding my task. How to achieve this?
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<script language="JavaScript">
function showInput() {
var message_entered = document.getElementById("user_input").value;
document.getElementById('display').innerHTML = message_entered;
}
</script>
</head>
<body>
<form>
<label><b>Enter a Message</b></label>
<input type="text" name="message" id="user_input">
</form>
<input type="submit" onclick="showInput();"><br />
<label>Your input: </label>
<p><span id='display'></span> </p>
</body>
</html>
var data = "<p>This is new tab'</p><br/>"+message_entered;
newWindow = window.open("data:text/html," + encodeURIComponent(data),
"_blank", "width=200,height=100");
newWindow.focus();
DEMO
I have the below code which launches the page and sets the zoom to 175%. I would like to do this for the w3schools link below...e.g. in a child window if anyone knows how. thanks .
IE 8 compatible, dont care about other browsers at the moment.
<html>
<head>
<title>olecmdid</title>
<script>
function zoom(percent) {
var PROMPT = 1; // 1 PROMPT & 2 DONT PROMPT USER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
var status = WebBrowser1.QueryStatusWB(63);
document.getElementById("QueryStatusWB_Result").innerHTML = status;
WebBrowser1.ExecWB(63,PROMPT,percent,null);
WebBrowser1.outerHTML = "";
}
</script>
</head>
<body onload="zoom(175);">
<form name="form">
<input type="Button" value="25%" onclick="zoom(25);">
<input type="Button" value="50%" onclick="zoom(50);">
<input type="Button" value="100%" onclick="zoom(100);">
<input type="Button" value="150%" onclick="zoom(150);">
<input type="Button" value="200%" onclick="zoom(200);">
</form>
Visit W3Schools.com!
</body>
</html>
I managed to get a workable solution for what I needed. So I resize the existing window and then launch a new window and then go back and resize the original window. Might help someone else.
<html>
<head>
<meta http-equiv="x-ua-compatible" content="IE=10">
<script>
function openwind() {
zoom(400);
var purchaseWin = window.open("test.html", "Google", "width=600, height=600");
setTimeout(function(){
zoom(100);
}, 500);
}
function zoom(percent) {
document.getElementById('WebBrowser1').ExecWB(63,2,percent,null);
}
</script>
</head>
<body>
<input type="button" value="Open window 400% Zoomed" onclick="openwind()">
<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>
</body>
</html>