I wish to make a redirection in a Google Apps Script embedded in a Google Site. I use HtmlService: when the user click a button, it starts a function containing window.location = adress_I_want_to_redirect.
Unfortunatly, it doesn't work. I tried with jQuery and $('location').href(adress_I_want_to_redirect) but it doesn't work either (quite logical ^^). Console displays The property 'href' is not writable.
Do you know an other way to do redirection which will work in GAS?
Thank you!
It may be that the Caja engine is preventing you from doing a redirection like this. You may need to use a regular anchor tag instead.
Related
I won't bore everyone reading this post with the entire background story of why I need to do this. However, I am looking to load the Google Compose Mail page in the HTML form loaded inside a Google Sheet I have created.
I know the link for the Compose email is https://mail.google.com/mail/u/0/?view=cm&fs=1&tf=1&to=TO&su=SUBJECT&body=BODY
But I don't know if it is possible to have this link loaded as a view in the HTML service Form.
Does anyone know if this is possible and if so, how to do it?
I could always have a button to load the link in a separate tab... but I would like to have this all kept on screen to be more "professional" looking.
I was looking for an option to add an iframe or free code, but option exists. I recommend inserting a form if you are looking for a way to get data from users.
Its under "Insert", then "Form..."
Good Luck
I have a form that I have implemented using HtmlService. When I submit it I want to see different Html page instead of the page with the form on it. Basically this new page should replace the form page. How do I go about doing this. I tried to create a template form from the process form function that gets called when the form is submitted. But it didn't work. Help me out with this please.
See this answer for an example of serving multiple html pages using HtmlService. The basic idea is to write doGet() to accept a query parameter that it will use to select which html page to serve.
I am not aware of any server-side redirect mechanism (that you could use in the template, that is). However, one way how to do it is via Ajax, client-side. See, for example, how I did it in VALET (open index.html and look from line 240 on).
As an aside: I also tried reloading a page which seemed not to work (maybe due to the restrictions re the window and document object.
You can use doPost() with HTML Services to load another html page.
See this answer.
I am working on my first site using google scripts. I have a script embedded that creates a UI and references a Google spreadsheet to link to pages of the same site. Whenever a link is clicked I get an interim page that says:
The previous page is sending you to
https://sites.google.com/site/gchromeat/xxxx.
If you do not want to visit that page, you can return to the previous
page.
Is there a way to get around this?
The behavior can be replicated here: https://sites.google.com/site/gchromeat/home/access
There's no way to go around this, as it seems to be a designed behavior. But there's an issue opened regarding this, you should star it to keep track of updates and kind of vote for it.
I presume you have used an Anchor object in your Google Apps Script. The reason why you get the redirect message is because the anchor object changes the link.
Browsers detect the redirect and ask for user confirmation (browser settings can be changed to avoid this).
Also see issue 1376 - which has been opened for getting rid of some undesirable side effects of this.
I want to overload navigator.geolocation.getCurrentPosition and navigator.geolocation.watchPosition to simulate geolocation during
development. Is it possible to do it using Google Chrome extension?
You mean something like this?
navigator.geolocation.getCurrentPosition = function(successCallback, errorCallback) {
successCallback({coords:{lattitude:10, longitude:20}});
}
If it is just for your own needs then it would be much easier to just do it in your js code.
If you want to make extension out of it then:
This code needs to be injected on every page of your app (via content script) and put inside dynamically created <script> tag, otherwise you will be inside content script sandbox and your overwritten function will not be visible to the parent page.
You would need to run this code before your app uses geolocation. There is no easy solution for this.
Now there's a chrome extension that does just that - the manual geolocation chrome extension. It tries its best to inject the script before any other one.
I found the extension what you want:)
https://chrome.google.com/webstore/detail/change-geolocation/njjpmclekpigefnogajiknnheheacoaj
I have been trying to locate an example of remote Javascript execution from a local HTML 'a' tag. This is not going to be a malicious execution. On my index page, I use Javascript to hide divs and bring a single div to the front - in order to have multiple pages on one (in a nutshell). I typically do this using the following example snippet:
About Us
However, on a different PHP/HTML page on the same site, I would like to have links that will execute the Javascript in the same fashion, only after pushing the browser to the new HTTP request. For example, in my inept-thinking, I would expect it to work like this:
About Us
This was a failure - as my Firefox renders the hyperlink as plaintext, and not clickable. I've scoured Google and this site for info, but found no examples. I would appreciate any feedback.
Thanks.
My understanding is that you want to invoke the same JavaScript function in multiple pages. How about using the script src tag as follows:
<script src="../common.js"></script>
I believe the src attribute can be a remote js file, but haven't tested it out.
Therefore, no matter what page you want to use the JavaScript to show the about us footer, you can have the same link:
About Us
So... you want to have the browser navigate to http://samedomain.com and then execute javascript:footerAbout()?
How about passing an argument as part of the address? Something to the effect of:
http://samedomain.com&show=footerAbout
http://samedomain.com#footerAbout
Then reading the URL in your destination page and letting the destination execute footerAbout()?