Reg: How to activate clicking in a second web page opened

1,119 views
Skip to first unread message

2morow never comes

unread,
Jan 27, 2020, 5:19:31 PM1/27/20
to Google Apps Script Community
Hi,
I have a link in the google sheets, which when clicked using custom function, will open as a new web page, in that i have to click send button automatically. Can anyone, help me how to incorporate this..
i have used  the below code to open URL, but then i have to make send action in that.. How to do that.
/**
 * Open a URL in a new tab.
 */
function openUrl( url ){
  var html = HtmlService.createHtmlOutput('<html><script>'
  +'window.close = function(){window.setTimeout(function(){google.script.host.close()},9)};'
  +'var a = document.createElement("a"); a.href="'+url+'"; a.target="_blank";'
  +'if(document.createEvent){'
  +'  var event=document.createEvent("MouseEvents");'
  +'  if(navigator.userAgent.toLowerCase().indexOf("firefox")>-1){window.document.body.append(a)}'                          
  +'  event.initEvent("click",true,true); a.dispatchEvent(event);'
  +'}else{ a.click() }'
  +'close();'
  +'</script>'
  // Offer URL as clickable link in case above code fails.
  +'<body style="word-break:break-word;font-family:sans-serif;">Failed to open automatically. <a href="'+url+'" target="_blank" onclick="window.close()">Click here to proceed</a>.</body>'
  +'<script>google.script.host.setHeight(40);google.script.host.setWidth(410)</script>'
  +'</html>')
  .setWidth( 90 ).setHeight( 1 );
  SpreadsheetApp.getUi().showModalDialog( html, "Opening ..." );
}

Alan Wells

unread,
Jan 27, 2020, 6:22:37 PM1/27/20
to Google Apps Script Community
window.onload will run with the web app opens

window.onload = function() {
 
//Code here will run when web app loads

}

2morow never comes

unread,
Jan 28, 2020, 6:45:13 AM1/28/20
to google-apps-sc...@googlegroups.com
Hi Alan,
I am trying to open WhatsApp web and send message to automatically from sheets.
If I use window.onload, then what is the equivalent of button click in app script to js ...


--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/77fcf1ba-bdc1-4adf-adb1-d26c1b7a1606%40googlegroups.com.

Alan Wells

unread,
Jan 28, 2020, 9:08:05 AM1/28/20
to Google Apps Script Community
You can get the html element, and then use the click method:

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

2morow never comes

unread,
Feb 1, 2020, 2:56:01 PM2/1/20
to google-apps-sc...@googlegroups.com
Hi Alan,
If i use the above also, i am not able to achieve automatic send of whatsapp message..
https://api.whatsapp.com/send?phone=xxxx"

The above api , which i use and am trying to send messages to different person based on sheet..

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/156847b8-fee3-4eec-b5ac-f4d77bb8cdb7%40googlegroups.com.

Alan Wells

unread,
Feb 1, 2020, 3:20:15 PM2/1/20
to Google Apps Script Community
I'm not familiar with whatsapp.
I can't help you with that.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

priya praja

unread,
Sep 11, 2020, 2:19:47 PM9/11/20
to Google Apps Script Community
if you solve your problem then plz help me.
how can click a whatsapp sand button. 

Reply all
Reply to author
Forward
0 new messages