1

I'm coding an google app script which grab selected text as parameter and open new window via a bookmarklet. I'm trying select&drag&drop some text or link to web application input/textarea which works on opened window example: https://script.google.com/macros/s/.../exec?article=.

The problem is when I allow iframe with .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL) and add https://script.google.com/macros/s/.../exec?article= page in an iframe instead of opening in a new page; drag&dropping text became disabled. Is there anyway to enable drag&drop text to iframe's input box?

drag&drop is available in normal https://script.google.com/macros/s/.../exec?article= page but not in an iframe.

Also thanks to comments I tried it on Firefox and it works, but still not on Chrome

GAS

function doGet(e) {
  return HtmlService.createHtmlOutput('')
    .append('<input type="text" id="kind" placeholder="Kind" size="4" value="' + (e.parameter.article?e.parameter.article:"") + '">')
  .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
  Logger.log(e);
}

Bookmarklet opening new page

javascript:if(window.getSelection)s=window.getSelection(); else if(document.getSelection)s=document.getSelection(); else if(document.selection)s=document.selection.createRange().text;     open('https://script.google.com/macros/s/...GAS.ID.../exec?article=article'+(location.host=='scholar.google.com'?'':'&pdf='+encodeURIComponent(location.href))+'&bib='+encodeURIComponent(s.toString())+'bib');0

Bookmarklet adding iframe

javascript:if(window.getSelection)s=window.getSelection();else if(document.getSelection)s=document.getSelection();else if(document.selection)s=document.selection.createRange().text;    iframe=document.body.appendChild(document.createElement('iframe'));iframe.style='position:fixed;bottom:0;z-index:99999;width:280px;'; iframe.src='https://script.google.com/macros/s/...GAS.ID.../exec?article=article'+(location.host=='scholar.google.com'?'':'&pdf='+encodeURIComponent(location.href))+'&bib='+encodeURIComponent(s.toString());0

*replace "/...GAS.ID.../" with web application id in bookmarklet

yun o
  • 11
  • 3
  • [Related?](https://stackoverflow.com/questions/16968818) – TheMaster Aug 16 '19 at 20:34
  • Yes, I think it is. But there isn't any solution either – yun o Aug 17 '19 at 07:43
  • [Edit] your post to include the browser that you're testing with. Does Firefox work? If it's a browser specific issue, then you need to open a bug report at that browser's bug tracker – TheMaster Aug 17 '19 at 08:14
  • [Comment#12](https://bugs.chromium.org/p/chromium/issues/detail?id=251718#c12) has a workaround. Also see related [answer](https://stackoverflow.com/a/56400626). – TheMaster Aug 17 '19 at 08:36
  • @TheMaster thanks for the links, I was hoping an attribute like sandbox ="allow-drag-drop" but probably there no way around – yun o Aug 17 '19 at 08:53

0 Answers0