首页 文章

Google Script拒绝将Google链接作为链接@ google文档插入

提问于
浏览
0

您能否给我一个解决方案或其他方式来处理警报消息或通过HTML链接中的侧边栏处理谷歌文档链接,我得到格式错误的HTML conten错误,如果我替换常规链接,如www.google它找不到工作 .

这里的错误按摩看起来像enter image description here

完整的细节:

格式错误的HTML内容:hi byhhttps://docs.google.com/open?id = 185g8pZGceMlIqmhEsYV8tkfxKsiRd_P3thjzLiX0Y target = _blank> test http://www.google.com> .

My code is the following :

function test0001()
{

  var doc = DocumentApp.getActiveDocument(); 
  var docurl = doc.getUrl(); 

  //var x = Gconvertlinko() ;
  var ui = HtmlService.createHtmlOutput('hi '+ 'bye' + "<a href="+ docurl+"  target=_blank > test </a>"+ "
<input type="+' text'+" name="+ 'lname'+ " value="+ "http://www.google.com" +">") /*.setContent( DocumentApp.getActiveDocument.getUrl() + "
"+ DocumentApp.getActiveDocument.getUrl() ) */ .setTitle('Google Convertor'); DocumentApp.getUi().showSidebar(ui); }

如果您有任何想法或想法处理,请告诉我 .

1 回答

  • 1

    你的 docurl 变量有一个等号,这导致了这个 . 最后, <a> 标签将具有属性 href=https://docs.google.com/open?id=185g8pZGceMlIqmhEsYV8tkfxKsiRd_P3t3mhjzLiX0Y . 请注意,有两个等号是无效语法 .

    要解决这个问题,只需将单引号放在docurl上:

    ui = HtmlService.createHtmlOutput('hi '+ 'bye' + "<a href='"+ docurl+"'  target=_blank > test </a>"+ "
    <input type="+' text'+" name="+ 'lname'+ " value="+ "http://www.google.com" +">")

相关问题