Button to run a script AND open a web page - google-apps-script

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?

Related

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

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:
.
.

Activating script via button press on embedded Google Sheet

I am trying to embed a Google Spreadsheet that has a script I'd like users to be able to activate. I don't want them to be able to edit anything on the page.
I thought I could do this by
Share sheet and set to edit permissions
Restrict editing on the one sheet I want to share (the images sit above the cells, so I thought this would prevent people from editing cells but allow them to click on the button
Publish to the web
Embed the sheet
Here is the iframe I used:
<iframe width="1250" height=1000 src="https://docs.google.com/spreadsheets/d/e/2PACX-1vRRajy1TK9Y9YQg-Df3bwTy9ktxPECq6T5gS7UfkrYpV_osxwDwRuQClC168B8-o4KsCdFl4kfMYtau/pubhtml?gid=1796260078&single=true&widget=true&headers=false"></iframe>
For context the scripts hide or show different rows. Clicking "show game 2" hides a section of rows and "show game 1" unhides these rows.
The sheet embeds okay but isn't interactable. I have turned off the restricted editing to test (it's back on) and that didn't allow people to edit anything, so I am not sure what I am doing wrong here.
Any help would be greatly appreciated! Cheers!
Workaround:
Use a another button outside the embedded spreadsheet instead.
Publish a headless web-app from your sheet using doPost()
On Button click, use JavaScript to post from your website to apps script web-app
On receiving post request, hide/show the rows using your original script.
References:
Web-app

Modify DOM in content-script as a replacement for the non-ability to trigger pop-ups programmatically?

I'm working on an extension that's supposed to use the content of the page to determine whether to show an interface to the user.
The ways to show an interface, if I'm correct, are using a browser action or a page action.
And neither can be triggered programmatically. But content scripts could be written to inject an equivalent GUI into the webpage.
So, does it make sense to modify the DOM using content-scripts to display an interface as a substitute for page action? It seems like an obvious work around to me, and I'm sure there are good reasons to not let page actions be triggered programmatically.
Well, modifying DOM must be done by only Content Scripts, as that is the reason they exist.
Want to fetch any data from current page, alter anything in the page, add new UI in the page - whatever, content script will help you do that.
It has nothing to do with Page script Or Browser Script.
YES, you can not programatically trigger page/browser action. It has to be done by explicit clicking.
But if you want to open a UI by clicking a chrome extension, then there is a popup js for that.

Adding Button in Gmail for web users

I am trying to figure out how can I add a button to the Gmail compose window.
Please see the image below for better idea..
Using Google App Script I have achieved some functionality where we can create almost anything, but How can We create a button in Gmail?
Even if not compose window as shown in image above, I will like to learn how to add button at any place in Gmail.com's window using gadget or any other way.
Note: I have tried many things and ended up nowhere, The Sidebar is deprecated by google so please don't highlight that..
I will be glad if any working code to add button in Gmail available,
Thanks in advance

How do you get the url of the script your running in Google scripts?

If your making a script using the Google script editor, how do you get the url of the script your running in the google script editor in google docs? (sorry for not capitalizing the word google)
If I'm understanding your question, you can choose the "Publish" -> "Deploy As a Web App..." menu item. From there, the pop-up will show "Deploy as Web App" with a text box underneath containing the URL. Grab that (or click the "latest code" link just below it). You don't have to follow-through on the re-deploy (if you do, you'll want to use the URL it presents in a pop-up after doing so)
If you haven't previously deployed it, you'll need to save a "version" and deploy it, as touched on here. Upon doing that, it will present you with the Url in a pop-up as mentioned above. If you miss it, the the first part of this answer applies.