<html>
<head>
<title>Window Object Methods - RJM Programming - June, 2022 ... thanks to https://www.w3schools.com/jsref/obj_window.asp</title>
<script type='text/javascript'>
var soh='';
var template="const prompt = (one,two) => { window.prompt(one,two); };";
var newt='';
var one='', two='', three='', four='';

function setitup(tv, newnewt) {
var thisih='';
var suff=';';
var varsare=[], ivars;
if (tv.indexOf('(') != -1 && tv.indexOf('()') == -1) {
if (newnewt != '') {
newt=newnewt;
document.getElementById('myh4').style.backgroundColor='orange';
} else {
document.getElementById('myh4').style.backgroundColor='yellow';
newt=template.replace(/prompt/g, tv.split('(')[0]).replace(/one\,two/g, tv.split('(')[1].split(')')[0]);
}
vars=tv.split('(')[1].split(')')[0].split(',');
for (ivars=0; ivars<vars.length; ivars++) {
if (document.URL.indexOf('popup=') != -1) {
thisih+=' ' + vars[ivars] + '=window.prompt(' + "'Please enter value for " + vars[ivars] + "',''); ";
} else {
document.getElementById('i' + vars[ivars]).style.display='block';
if (newnewt == '') {
document.getElementById('i' + vars[ivars]).value='';
}
thisih+=' document.getElementById(' + "'i" + vars[ivars] + "'" + ').value=' + "'' + " + vars[ivars] + '; document.getElementById(' + "'i" + vars[ivars] + "'" + ').style.display=' + "'block'" + '; ';
}
}
if (newt.indexOf(tv.split('(')[1].split(')')[0] + ')') != -1) {
suff=newt.split(tv.split('(')[1].split(')')[0] + ')')[eval(-1 + newt.split(tv.split('(')[1].split(')')[0] + ')').length)].split('}')[0];
}
//suff+=' valnone(); ';
if (newt.indexOf('window.') != -1) {
thisih+=' ' + newt.split('{')[1].split('window.')[0] + ' ' + tv.split('(')[0] + '(' + tv.split('(')[1].split(')')[0].trim() + ')' + suff + ' ';
} else {
thisih+=' ' + tv.split('(')[0] + '(' + tv.split('(')[1].split(')')[0].trim() + ')' + suff + ' ';
}
document.getElementById('myh4').innerHTML="<a title='Double click to make happen' ondblclick=\"" + thisih + "\" style=text-decoration:underline;cursor:pointer;>" + newt + "</a>";
eval(newt);
}
}

function changeyours(divo) {
var tih=(divo.innerText || divo.contentWindow || divo.contentDocument);
//alert('tih=' + tih);
if (tih.indexOf('window.') != -1) {
//alert('arg 1=' + tih.split('window.')[1].split(';')[0]);
setitup(tih.split('window.')[1].split(';')[0], tih);
} else {
//alert('Arg 1=' + document.getElementById('mysel').value);
setitup(document.getElementById('mysel').value, tih);
}
}

function valnone() {
document.getElementById('ione').style.display='none';
document.getElementById('itwo').style.display='none';
document.getElementById('ithree').style.display='none';
document.getElementById('ifour').style.display='none';
}

function onl() {
}
</script>
</head>
<body onload="onl();">
<h1>Window Object Methods</h1>
<h2>RJM Programming - June, 2022</h2>
<h3>Thanks to <a target=_blank href='//www.w3schools.com/jsref/obj_window.asp' title='https://www.w3schools.com/jsref/obj_window.asp'>https://www.w3schools.com/jsref/obj_window.asp</a></h3>
<input onblur="one=this.value;" style="display:none;" id=ione placeholder="one" type="text" value=""></input>
<input onblur="two=this.value;" style="display:none;" id=itwo placeholder="two" type="text" value=""></input>
<input onblur="three=this.value;" style="display:none;" id=ithree placeholder="three" type="text" value=""></input>
<input onblur="four=this.value;" style="display:none;" id=ifour placeholder="four" type="text" value=""></input>
<h4 id=myh4 contenteditable=true onblur='changeyours(this);'>Will show here your Javascript code happening.</h4>
<br>
<select id=mysel onchange="valnone(); setitup(this.value,'');"><option value=''>Please choose a Window Object method to make your own ...</option>
<option value="alert(one)">alert() Displays an alert box with a message and an OK button</option>
<option value="atob(one)">atob() Decodes a base-64 encoded string</option>
<option value="blur( )">blur() Removes focus from the current window</option>
<option value="btoa(one)">btoa() Encodes a string in base-64</option>
<option value="clearInterval(one)">clearInterval() Clears a timer set with setInterval</option>
<option value="clearTimeout(one)">clearTimeout() Clears a timer set with setTimeout</option>
<option value="close( )">close() Closes the current window</option>
<option value="confirm(one)">confirm() Displays a dialog box with a message and an OK and a Cancel button</option>
<option value="focus( )">focus() Sets focus to the current window</option>
<option value="getComputedStyle(one)">getComputedStyle() Gets the current computed CSS styles applied to an element</option>
<option value="getSelection( )">getSelection() Returns a Selection object representing the range of text selected by the user</option>
<option value="matchMedia(one)">matchMedia() Returns a MediaQueryList object representing the specified CSS media query string</option>
<option value="moveBy(one,two)">moveBy() Moves a window relative to its current position</option>
<option value="moveTo(one,two)">moveTo() Moves a window to the specified position</option>
<option value="open(one,two,three)">open() Opens a new browser window</option>
<option value="print( )">print() Prints the content of the current window</option>
<option value="prompt(one,two)">prompt() Displays a dialog box that prompts the visitor for input</option>
<option value="requestAnimationFrame(one)">requestAnimationFrame() Requests the browser to call a function to update an animation before the next repaint</option>
<option value="resizeBy(one,two)">resizeBy() Resizes the window by the specified pixels</option>
<option value="resizeTo(one,two)">resizeTo() Resizes the window to the specified width and height</option>
<option value="scroll(one,two)">scroll() Deprecated. This method has been replaced by the scrollTo method.</option>
<option value="scrollBy(one,two)">scrollBy() Scrolls the document by the specified number of pixels</option>
<option value="scrollTo(one,two)">scrollTo() Scrolls the document to the specified coordinates</option>
<option value="setInterval(one,two)">setInterval() Calls a function or evaluates an expression at specified intervals (in milliseconds)</option>
<option value="setTimeout(one,two)">setTimeout() Calls a function or evaluates an expression after a specified number of milliseconds</option>
<option value="stop( )">stop() Stops the window from loading</option>
</select>