3

Google サイトを使用して、HTML リンクを同じウィンドウで開く方法はありますか?

カスタマイズが非常に限られているため、ボタン ウィジェットは避けたいと思います。

すでにこれを試しましたが、うまくいきませんでした

<a href="https://www.google.com" target="_PARENT">Google.com</a>

<a href="" onclick="Window.open('https://www.google.com','_parent')" >Google.com</a>

ところで、Google サイトでは、HTML ウィジェットを挿入すると、IFRAME が作成されます。このiframeからリンクを同じウィンドウで開けるようにしたいです。

4

2 に答える 2

-1

ボタンまたはメニュー オプションをクリックすると、ブラウザの別のタブで URL を開くことができます。

同じブラウザウィンドウの別のタブでGoogleドキュメントを開くメニューオプション「ヘルプ」に使用する以下のコードを提供しています。どのブラウザでも動作します。

//
//
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 ..." );
}
//
//
function open_help(){
 openUrl("https://docs.google.com/document/d/..../edit");//this is the help file Google Doc
}
//
//



于 2020-04-16T04:14:30.947 に答える