Force iFrame links (in embedded Google Doc) to open in new window

后端 未结 3 2087
一个人的身影
一个人的身影 2021-01-01 23:46

Very oddly, there seems to be no way of setting Google Document links to open in a new window. (target=\"_blank\").

When publishing a Google Doc and using the embed

3条回答
  •  盖世英雄少女心
    2021-01-02 00:32

    OK, in lack of a better alternative I decided to Curl the Google Doc URL and do some jQuery magic before loading it in an iFrame.

    Curl.php

    curl_setopt($ch, CURLOPT_URL, $Url);
    [...]
    $("#header").hide()
    $("#footer").hide()
    $('a[href^="http://"]').attr("target", "_blank");
    

    Page.html

    $("#google_content").html("");
    

    Google, is this really the recommended workaround? ;)

提交回复
热议问题