I've to fill a texbox in an external website with a google app script based on google sheets. Is it possible?
For exemple I've to fill the textbox named "textbox1" in the website www.website.com,
To open the website the code is :
function myFunction() {
var js = "<script>window.open('www.website.com','_blank', 'width=800, height=600'); \
google.script.host.close(); ;</script>";
var html = HtmlService.createHtmlOutput(js);
SpreadsheetApp.getUi().showModalDialog(html, 'Now loading.');
}
normaly the code would be
document.getElementByName("textBox1").setAttribute("value","something")
but it doesn't work with google app script. Can you help me to understand how it works?
More Informations :
In my situation I have to click on a button on google sheets which will open a web page (not google suite) and automatically fill out a form (of course I know the names of the fields in advance as well as the data to put). My problem is therefore to modify an HTML page via an app script.
On Excel it was possible to do this with the InternetExplorer package which includes HTMLDocument for example.
Thanks a lot in advance !
Related
Suppose you open an HTML page on web it has url like :
https://storage.googleapis.com/fasdcjh-jdfsdf/ga/123/test.html
I want to put some javascript in test.html so that the url changes to
lkasdjhfklahsdfklasjdflahfd (some random string)
The test.html is my creation so i can modify it to achieve it.
what i tried :
Insert this script in the html
<script type="text/javascript">
window.history.replaceState(null,'title','asdakjsdhjkad');
</script>
It changed the url to - https://storage.googleapis.com/fasdcjh-jdfsdf/asdakjsdhjk
So the last part did got changed. But the domain storage.googleapis.com and the rest of the string in path didnt.
How to achieve that ?
PS:
The HTML files will be uploaded to a google cloud storage account.
The above script worked when accessing the document from the google cloud storage but only hiding the last part
I am currently redesigning a page on SharePoint and I am having trouble with adding in a pop up window when a new page opens. I want the user to click into a new page and when the new page opens, a pop up window appears with a message.
I am fairly new to SharePoint and hence why I am finding this difficult.
I have seen solutions using JQUERY, Javascript, HTML etc but not sure how to exactly implement it using SharePoint (on .aspx page)
I would like to avoid JQUERY and Javascript at all costs as they are not my strongest areas.
Is it a case of adding a new Web Part and embedding the code in there or?
Any help would be greatly appreciated.
Add a Script Editor Webpart (Sharepoint 2013) Then add code given below
$(document).ready(function(){
$('#overlay, #popup').css('display', 'block');
$('#overlay').click(function(){
$('#overlay, #popup').css('display', 'none');
});
});
Add Content Editor webpart and then Add CSS and HTML there
<input type="button" id="btn" value="Click Here" />
<div id="overlay"></div>
<div id="popup"></div>
When comes to popup you can't completely avoid Javascript, Find complete code in Fiddle. (In fiddle example, instead of click add code in directly inside ready function)
http://jsfiddle.net/JRD06/sx0mjwe1/
or use this
https://fiddle.jshell.net/nikhilmangal/srg3gy26/light/
The JavaScript libraries included in SharePoint 2010 and SharePoint 2013 include methods for easily creating and displaying dialog boxes in a standard way.
For this, you simply execute SP.UI.ModalDialog.showModalDialog().
For example:
SP.SOD.executeOrDelayUntilScriptLoaded(showDialog,"sp.js");
function showDialog(){
var dialogOptions = SP.UI.$create_DialogOptions();
dialogOptions.title = "Your Title Here!";
var dummyElement = document.createElement("div");
dummyElement.innerHTML = "<h1>Your HTML Goes Here</h1>"
dialogOptions.html = dummyElement;
SP.UI.ModalDialog.showModalDialog(dialogOptions);
}
To get the JavaScript to run when the page loads, you can embed it in a web part.
In SharePoint 2010, save your JavaScript code into a text file (with <script> tags around it) and save it to a library on your SharePoint site, then add a Content Editor Web Part to the page where you want the code to run, and set the web part's "Content Link" property to the path of the text file.
In SharePoint 2013, use the Script Editor web part to embed the desired JavaScript.
I am creating a GUI using google sheets and google script. As of recently, that requires serving HTML with the GS code.
I have a google sheet, that, when opened, provides a pop-up for users to view some data. I have a script that within the html file that I would like to link to an external page. For example, consider this line of code in a text
document.getElementById("id1").innerHTML = 'Visit Google!';
In the small GUI window that is provided, if I left click the link, the GUI goes blank (white), and nothing else seems to happen. However, if I right click and open the link in a new page, it works fine.
Here is my question:
Why can I not left click to open the link?
Side question (I can post this separate if it is better etiquette on this site): Is there a way to increase the size of the GUI window provided by my google script? Or perhaps even open up the data in a new page with the html?
update: Stub for serving the html:
function openDialog() {
var html = HtmlService.createHtmlOutputFromFile('TeacherView')
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
SpreadsheetApp.getActive().show(html);
}
Thanks,
Jordan
Include the target="_blank" tag in the <a>.
Insteado of using show, use showModalDialog or showModelessDialog.
I need to collect the amount of clicks on a link, placed in email.
The idea is following:
1) I send an email message with 1 hyperlink to N people
2) Some of them open it and click this link.
3) Link directs to the file Sharepoint (this is required) page (Library or List) where the below code is placed:
<script language="javascript" type="text/javascript">
var Loginname = document.getElementById("zz15_Menu");
var strTrans=Loginname.getElementsByTagName('span')[0].innerHTML;
.... WHAT SHOULD BE HERE?....
window.location = "http://www.smth.com/ololo.pdf";
</script>
I have user's Display Name in strTrans now.
Please suggest something to code next to store this parameter of every page visit in some file, allowing me then to get the amount of link clicks.
I cannot use any server-side technology on Sharepoint.
The including of a javascript file is enough for Google and others to gather statistics, so why not use some tool like Google Analytics.
If you want to depend on javacript, you could use jQuery to open an url on the background and gather statistics in there.
Use something like this:
$.get('http://url/registerOpen.aspx?username=' + strTrans);
Setting aside the paid services (Omniture, WebMetrics, etc.), did you consider Google Analytics?
http://www.google.com/analytics/
My company is using a website that hosts all of our FAQ and customer questions. We have plans to go through and wipe out all of the old data and input new and the service does not have a backup, or archive option for questions we don't want to appear anymore.
I've gone through and tried to scape the site using perl and mechanize, but I'm missing the customer comments on the page as they are loaded through ajax. I have looked at phantomjs and can get the pages to save to an image using an example page, however, I'd like to get an full page html dump of the page, but can't figure out how. I used this example code on our site
var page = new WebPage();
page.open('http://espn.go.com/nfl/', function (status) {
//once page loaded, include jQuery from cdn
page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
//once jQuery loaded, run some code
//inserts our custom text into the page
page.evaluate(function(){$("h2").html('Many NFL Players Scared that Chad Moon Will Enter League');});
//take screenshot and exit
page.render('espn.png');
phantom.exit();
});
});
Is there a way using phantomjs that I can just get a full page dump of the data, similar to if I did a view source in chrome? I can do this with perl + mechanize, but don't see how to do this using phantomjs.
You can use page.content to get the full HTML DOM
I would recommend pjscrape http://nrabinowitz.github.com/pjscrape/ if you want to scrape using PhantomJS