visualizzatore di Google Docs in IE
-
04-10-2019 - |
Domanda
Ho cercato di alta e bassa per una soluzione, ma non riesce a trovare uno. Sto utilizzando Google Docs Viewer per visualizzare i file PDF. E 'un grande strumento, ma io non riesco a farlo funzionare in Internet Explorer (7 o 8). Tutte le mie immagini vengono su come icona 'mancante'. Se osservo il file dall'esterno, sembra per caricare fine e si inizierà a lavorare (sto assumendo perché le immagini vengono memorizzate nella cache). Il documento viene visualizzato in un iframe
e lavora a tutti gli altri browser. Qualcuno ha incontrato una soluzione per farlo lavorare in IE? In caso contrario, c'è un'alternativa in grado di visualizzare i file PPT e PDF?
Soluzione
L'unica soluzione che ho trovato a questo problema, è quello di aggiungere https://docs.google.com per i vostri siti internet di fiducia.
Altri suggerimenti
Ho lo stesso problema, ma non pensavo che fosse accettabile per avere a chiedere agli utenti di aggiungere l'URL per i loro siti attendibili in Internet Explorer.
Per fortuna mi sono imbattuto il seguente post :
La versione incorporata di Google Docs Viewer (gview) non verrà caricato le sue immagini correttamente se i cookie di terze parti vengono disattivate. Questo problema è un problema per la maggior parte degli utenti di IE, come per impostazione predefinita è disabilitata. Qui di seguito fornisco un lavoro intorno a questo problema per almeno fino a quando Google aggiunge un P3P. La discussione originale del problema può essere trovato alla Guida di Google Documenti forum.
Ho provato questo fuori e funziona in IE8, IE7 e IE6.
So che questa è una domanda vecchia, ma dal momento che il problema ancora persiste e che ho inciampato su questa questione con una risposta che punta a un sito web in bianco, ecco il codice vero e proprio dello script menzionata in risposta @codeinthehole , nel caso in cui qualcun altro ne ha bisogno. (Può essere trovato, questa volta, a GitHub )
<?php
# This proxy code is a bypass for an existing flaw in Google Docs Viewer that breaks the functionality
# for some IE users. If you do not wish to use this code, select Google Standard Viewer rather than
# Enhanced Viewer in GDE Settings. Note that viewer toolbar customization options depend on this
# proxy workaround remaining enabled.
#
# The problem this code addresses is discussed at length on Google's Help Forum:
# http://www.google.com/support/forum/p/Google+Docs/thread?tid=22d92671afd5b9b7&hl=en
#
# This code is based on the work of Peter Chen. For more information, see:
# http://peterchenadded.herobo.com/gview/
#
# Peter's code is modified below to allow for cURL fallback, viewer toolbar customization,
# and to reflect changes in the viewer since the code was first released.
// test for allow_url_fopen in php config; try curl for function if disabled
if (ini_get('allow_url_fopen') !== "1") {
if (function_exists('curl_version')) {
$curl = 1;
} else {
$err = "This function is not supported on your web server. Please add ";
$err .= "<code>allow_url_fopen = 1</code> to your php.ini or enable cURL library. ";
$err .= "If you are unable to do this, please switch to Google Standard ";
$err .= "Viewer in GDE Options.";
echo $err;
exit;
}
}
if (isset($_GET['embedded'])) {
// get the src page, change relative path to absolute
if (isset($curl)) {
$code = curl_get_contents("http://docs.google.com/viewer?" . $_SERVER['QUERY_STRING']);
} else {
$code = file_get_contents("http://docs.google.com/viewer?" . $_SERVER['QUERY_STRING']);
}
// fix path to images
$search[] = "/viewer/images";
$replace[] = "http://docs.google.com/viewer/images";
$search[] = "/gview/images";
$replace[] = "http://docs.google.com/viewer/images";
// proxy the javascript file
$search[] = "gview/resources_gview/client/js";
$replace[] = "?jsfile=gview/resources_gview/client/js";
if (isset($_GET['gdet'])) {
$gdet = $_GET['gdet'];
# hide google icon (i)
/* These are no longer visible by default - not necessary
if (strstr($gdet, 'i') !== false) {
$search[] = ".goog-logo-small {";
$replace[] = ".goog-logo-small { display: none !important;";
}
# hide single/double page view (p)
if (strstr($gdet, 'p') !== false) {
$search[] = ".controlbar-two-up-image {";
$replace[] = ".controlbar-two-up-image { display: none !important;";
$search[] = ".controlbar-one-up-image {";
$replace[] = ".controlbar-one-up-image { display: none !important;";
}
*/
# hide zoom in/out (z)
if (strstr($gdet, 'z') !== false) {
$search[] = "#zoomOutToolbarButtonIcon {";
$replace[] = "#zoomOutToolbarButtonIcon { display: none !important;";
$search[] = "#zoomInToolbarButtonIcon {";
$replace[] = "#zoomInToolbarButtonIcon { display: none !important;";
}
# hide open in new window (n)
if (strstr($gdet, 'n') !== false) {
$search[] = "#openInViewerButtonIcon {";
$replace[] = "#openInViewerButtonIcon { display: none !important;";
}
}
$code = str_replace($search, $replace, $code);
header('Content-type: text/html');
echo $code;
} else if (isset($_GET['a']) && $_GET['a'] == 'gt') {
// get text coordinates file, can not redirect because of same origin policy
if (isset($curl)) {
$code = curl_get_contents("http://docs.google.com/viewer?" . $_SERVER['QUERY_STRING']);
} else {
$code = file_get_contents("http://docs.google.com/viewer?" . $_SERVER['QUERY_STRING']);
}
header('Content-type: text/xml; charset=UTF-8');
echo $code;
} else if (isset($_GET['a']) && $_GET['a'] == 'bi') {
// redirect to images
header("Location: http://docs.google.com/viewer?" . $_SERVER['QUERY_STRING']);
header('Content-type: image/png');
} else if (isset($_GET['jsfile'])) {
// proxy javascript files and replace navigator.cookieEnabled with false
if (isset($curl)) {
$code = curl_get_contents("http://docs.google.com/" . $_GET['jsfile']);
} else {
$code = file_get_contents("http://docs.google.com/" . $_GET['jsfile']);
}
$search = array("navigator.cookieEnabled");
$replace = array("false");
$code = str_replace($search, $replace, $code);
header('Content-type: text/javascript');
echo $code;
} else {
// everything else, of which there isn't!
header("Location: http://docs.google.com/viewer?" . $_SERVER['QUERY_STRING']);
}
function curl_get_contents($url) {
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
return $file_contents;
}