Is there any way we can directly connect to the function without wanting to click the button i.e., when ever the page loads the function gets called - html

here is the Html button i want to disable the click function, reducing the extra step so that the function gets called whenever the page gets loded in the browser.
i want to scrape the data(info that comes after clicking the button) from this html file.
OR
Suggest me if we can dirctly call this JS function In Python
I tried Js2Py but cannot translate the Js File.
i have not tried anything as im not fimailar with html.
i'm supposed to modify the code according to my preferences and im a novoice in html.
i searched in google but couldnt find any relaiable source.

the answer is onload function on the Body tag of html instead for onclick it took a while to figure out.
before:
After:
.
.

Related

Location.href works strangely. Why?

I want to implement the function of moving to the corresponding link when I press each td. The link is stored in the Json file. However, when I checked this code with live server, I found that it moved to one of the links even though I didn't click it. How should I modify my code?enter image description here

Generate Amazon link for open side popup with pre-applied filters

Edit: Stackoverflow modify automatically the Amazon links when you click, so for see the popup, select, copy and paste the URLs in the browser.
On Amazon there is a link to open directly a side popup, like this:
https://www.amazon.com/dp/B07FKTZC4M/#aod (#aod open the popup)
where We can enter some filters. I tried different ways with no success to generate a link that open directly the site popup with new filter pre-applied.
So i need a link that open this page with "new filter" pre-applied:
I tried different solutions, but don't work, for example:
https://www.amazon.com/dp/B07FKTZC4M/ref=aod_f_new#aod
https://www.amazon.com/dp/B07FKTZC4M/ref=new#aod
https://www.amazon.com/dp/B07FKTZC4M/#aod_f_new=true
https://www.amazon.com/dp/B07FKTZC4M/ref=aod_f_new=true#aod
https://www.amazon.com/dp/B07FKTZC4M/ref=aod_f_new?ie=UTF8&f_new=true#aod
I see some informations on source page, maybe that help:
Question: Is there a way to create a link that open directly the side popup with new filter pre-applied? Maybe adding some parameters to the URL.
You can call a function in JavaScript with which you can change the z-index of the popup.
Something like this:
<button onclick="popup()" value="open popup">
Also make the popup. I am just making a rough one:
<div id="popup" style="z-index:1000; position: absolute;">Some code</div>
Remember to set the z-index at behind and the position. Then for JS i will make it simple in case you can't code JS
function popup(){
document.getElementById("popup").style.zIndex=-1;//basically changing the popup's z-index
}
This will just change the z-index of the popup which you must create yourself

Button to run a script AND open a web page

I have a button on my classic google site, that when pressed will run a script I have written. The script will either create a page or amend the html if it already exists. As I am using the 'button' to run the script, how do I show amended/created page?
From researching this, it appears that you cannot show a webpage using the script. That suggests that I would need to have the page linked to the button, but I am using that to run the script.
I am new to javascript and HTML, so my apologies if this should be obvious. The only thing I can think of is that the user would need to press the button to update the page and then press another link generated by the script when the updating was complete.
Can anyone point me in the right direction?

Open Help web page from Google script HTMLservice interface

I want to put a Help button on an HTMLservice interface. I have tried it directly on the button and also by calling the function below
function helpClicked() {
document.getElementById('payment').value = "Help Clicked...";
window.open("www.google.com")
}
This changes the payment field to validate that the button was clicked but does not open a new browser window with the url. Is there any way to make this happen?
Use a link (a tag) directly with the correct URL instead of a button and use css to make it look like a button (if you need one). You can still hook triggers to the link, but you won't need to do the window.open yourself, therefore avoiding this problem/limitation.

Dynamic html onClick

So I am playing around with the HTML service of GAS.
It has been working fine (more or less). But I hit a wall now.
I want the script (inside the html file) to create some html on when called.
In particular a few tags.
However, I want those tags to have onClick handlers (which will edit the div element).
Now the problem is that the onClick should depend on certain properties and I can not
pre-create those objects, they have to be made pragmatically and for some reason when I add a
onClick="someFunction(elementID)" after the new code has been added to the old one the click handler disappears.
(it works tho if the handler function has no parameters)
eg.
var div="<div id=\"box"+count+"\" class=\"square\" insert></div>";
if(something)
div=div.replace("insert", "onclick=\"myFunction(box"+count+"\"");
This is intentional and documented: see the section called "Dynamically adding scripts or external CSS" in the HtmlService user guide.