|
I built a Web server myself, want to achieve the entire browser minimization,except "JAVA" and "JSP", what method can achieve this effect. There are a lot of examples of browser minimization using "JS" on the internet, but none of them worked for me. Some people mentioned that it might be the ActiveX controls. I don't know what the problem is. Please help me to solve the problem, because I am a rookie, please tell me detailed , thank you very much! Here is an example of using JS for browser minimization that I found on the Internet:
<object id="min" classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Minimize" />
<object id="max" classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Maximize" />
<input type="button" value="minimize" οnclick="min.Click()">
<input type="button" value="maximize" οnclick="max.Click()">
|
|
|
|
|
Javascript cannot change the state of the browser window.
Imagine how annoying it would be if every scammy site you accidentally clicked through to immediately minimized your browser window to hide its nefarious activities!
And no, there is no workaround.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: immediately minimized your browser window to hide its nefarious activities! ... or set full screen (hiding the magic X) with an onanything() handler to restore itself...
Back in the day that caused quite a few heart attacks.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Why would you want to do this?
|
|
|
|
|
function confirmDescConfirmIcon(){
$.sendConfirm({
hideHeader: true,
withIcon: true,
hideClose: true,
autoClose: true,
bgHide: false,
escHide: true,
withCenter: true,
button: {
confirm: 'confirmed',
},
onConfirm: function(){
window.open('test.php','','depended=no,height=-200,width=-200,top=2000,left=2000,toolbar=no,menubar=no,scrollbars=no,location=no,status=no');
}
})};
confirmDescConfirmIcon();
This button page implements "window.open()" to open a new window.
I would like to ask how I can automatically bring the button page to focus if I am browsing another page and the button page is not closed. I don't want to use "window.open" again to bring the button page to focus.
Before, I tried to execute a certain page in the background, and then I wanted to use the "window.location.href" to a page that open a new window of the button page after a period of time, so that the button page becomes the focus of execution, but I failed.
Later I tried a page in the background using "window.location.href" to jump to the button page then the button page automatically become the focus, but failed!
Because I am new for js, trouble a little more detailed, please help me! Thank you very much!
|
|
|
|
|
You have already posted this in the thread immediately below this one.
Do not repost your question. If you do not get a reply, that suggests either you haven't provided enough information, or nobody has a solution for you. Posting the same question again will simply annoy people, and could get you banned from the site.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
function confirmDescConfirmIcon(){
$.sendConfirm({
hideHeader: true,
withIcon: true,
hideClose: true,
autoClose: true,
bgHide: false,
escHide: true,
withCenter: true,
button: {
confirm: '确定',
},
onConfirm: function(){
window.open('test.php','','depended=no,height=-200,width=-200,top=2000,left=2000,toolbar=no,menubar=no,scrollbars=no,location=no,status=no');
}
})};
confirmDescConfirmIcon();
This button page implements "window.open()" to open a new window.
I would like to ask how I can automatically bring the button page to focus if I am browsing another page and the button page is not closed. I don't want to use "window.open" again to bring the button page to focus.
Before, I tried to execute a certain page in the background, and then I wanted to use the "window.location.href" to a page that open a new window of the button page after a period of time, so that the button page becomes the focus of execution, but I failed.
Later I tried a page in the background using "window.location.href" to jump to the button page then the button page automatically become the focus, but failed!
Because I am new for js, trouble a little more detailed, please help me! Thank you very much!
|
|
|
|
|
Greetings experts,
I have a two part question but first what I am trying to accomplish and what I have tried so far.
Currently, we have a button on our web page with an Amend. value.
When you click the Amend button, a textbox is displayed which allows users to enter whatever text they wish to enter.
If user changes his/her mind after clicking Amend, users can click Cancel to hide the textbox again.
This works well.
The original intent is to allow users to enter data as an amendment to existing data and submit to the database.
Here is the working code:
$("#btconsultsup").click(function () {
if ($(this).val().toLowerCase() == "amend") {
$.each($('.consultsup'), function(i, item){
$(this).show();
});
$(this).val("Cancel");
} else {
$.each($('.consultsup'), function(i, item){
$(this).hide();
});
$(this).val("Amend");
}
});
<input id="btconsultsup" type="button" value="Amend" name="btconsultsup" />
<div class="consultsup" style="display: none"><input class="shortCosts" id="amendconSupportContractCosts" name="amendconSupportContractCosts" value=""/></div>
However, management has decided that once data is entered into this textbox, (A), once you click Amend button to display the textbox, then Cancel button should be hidden because they want the textbox to display permanently on the page even after the page is closed and reopened; and (B), data should displayed permanently on that textbox.
So, how do I hide the Cancel button so it will no longer be available to users to click on it to hide the textbox once it is already displayed?
Two, how do I ensure that once the Amend button is clicked and textbox is displayed, that it remains displayed even after the page is closed and reopened.
I had suggested to them that the best solution is to just add the textbox to the page without the need for Amend button but they refused.
Any suggestion is greatly appreaciated.
modified 5-Jul-21 9:49am.
|
|
|
|
|
Assuming your server-side code outputs the stored value from the database in the textbox, then you simply need to test on page load whether the textbox is empty, and display it if it has a value.
$(function(){
const displayShortCosts = function(){
$(".consultsup").show();
$("#btconsultsup").hide();
});
if ($("#amendconSupportContractCosts").val()) {
displayShortCosts();
}
else {
$("#btconsultsup").click(displayShortCosts);
}
});
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 5-Jul-21 9:39am.
|
|
|
|
|
Hello Richard,
Thank you very much sir for your awesome response.
Just one follow up question.
So your solution and my JS would work together as shown below?
$(function(){
const displayShortCosts = function(){
$(".consultsup").show();
$("#btconsultsup").hide();
});
if ($("#shortCosts").val()) {
displayShortCosts();
}
else {
$("#btconsultsup").click(displayShortCosts);
}
});
$("#btconsultsup").click(function () {
if ($(this).val().toLowerCase() == "amend") {
$.each($('.consultsup'), function(i, item){
$(this).show();
});
$(this).val("Cancel");
} else {
$.each($('.consultsup'), function(i, item){
$(this).hide();
});
$(this).val("Amend");
}
});
|
|
|
|
|
You wouldn't need your script.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Just a little confused by this:
if ($("#shortCosts").val()) {
I have it as a class in my HTML:
|
|
|
|
|
Sorry, should be:
if ($("#amendconSupportContractCosts").val()) {
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Perfect, perfect!!!
Thank you so much sir.
Incredible!
|
|
|
|
|
program for consecutive characters which are same, omit one if consonents and do nothing if they are vowel in javascript
|
|
|
|
|
Sorry, this site does not provide code to order. Do yourself a favour and learn to do your own work. Start at: JavaScript Tutorial[^]
|
|
|
|
|
hello! I’m a beginner on coding.
I have an javascript
setInterval(function() ideally that will auto play a audio at an exact time. Now I want to use a html button to trigger the setInterval(function(). The timer works ok as I’ve tested by using an alert. Please advise if the below codes are ok to do an autoplay audio function?
thanks
the audio in HTML:
<div id="time"></div>
<audio controls style="display: none;">
<source src="audio.mp3" type="audio/mpeg" />
</audio>
the javascript:
setInterval(function() {
var d = new Date(),
hours = d.getHours(),
min = d.getMinutes(),
sec = d.getSeconds();
if (hours === 16 && min === 25 && sec === 01) {
var audio = document.getElementsByTagName('audio')[0]
audio.play()
audio.style.display = 'block'
}
}, 1000)
|
|
|
|
|
Member 15265438 wrote: Please advise if the below codes are ok to do an autoplay audio function? What happens when you try it?
|
|
|
|
|
it won’t auto-play the audio… I’ve ask someone else and said user need interact with the webpage first to play an auto-play action. So I wonder if I can use a button the trigger the javascript?
|
|
|
|
|
|
Two obvious problems here:
1) Playing audio or video except as a direct result of user interaction is generally blocked. This includes playing the audio some time after the user has clicked a button - whilst some browsers might give you a small amount of leeway, playing audio minutes after the user clicked the button is likely to be blocked.
2) Javascript timers are not guaranteed to fire at a precise time. The setInterval callback will not be called more than once per second, but there is no guarantee that it will be called at least once per second. This is particularly problematic if your page is in the background, where the timer resolution will be decreased to conserve power.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thanks for the explaining.
So can you give any advise that would make it happen?
What I want to do sounds simple: when people go to the website and audio will auto-played at a specific time…
I understand browser will have restrictions on this but will there any ways could make it happen?
thanks
|
|
|
|
|
If you can convince the users to change their settings for your site to allow it to auto-play audio without user interaction, then you might be able to get close. You would need to change your test to see if the current time was greater than or equal to the desired time, rather than checking that it's precisely equal to the desired time. Once the desired time has passed, clear the timer to stop it from checking every second.
const playAudio = function(){
const audio = document.querySelector("audio");
audio.style.display = "block";
audio.play();
};
const shouldPlayAudio = function(){
const now = new Date();
const h = now.getHours();
if (h > 16) { return true; }
if (h < 16) { return false; }
const m = now.getMinutes();
if (m > 25) { return true; }
if (m < 25) { return false; }
const s = now.getSeconds();
return s >= 1;
};
let autoPlayTimer = null;
const playAtTime = function(){
if (shouldPlayAudio()) {
clearInterval(autoPlayTimer);
autoPlayTimer = null;
playAudio();
}
};
autoPlayTimer = setInterval(playAtTime, 1000); Demo[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I am new to js and might be a silly question. sorry for that as I started to learn JS.
I have made 2 scripts. 1 for autoclick buttons and another 1 for autoclick nextpage button.
How to merge both codes to one after one. also I need to set 5 seconds delay between both this scripts.
Script 1:
var buttons = document.getElementsByClassName('Polaris-Button');
for(var i = 0; i <= buttons.length; i++)
buttons[i].click();
Script 2:
var btn = document.getElementsByClassName('ant-pagination-next');
for(var s = 0; s <= btn.length; s++)
btn[s].click();
Thanks in advance.
|
|
|
|
|
|