【问题标题】:Google Docs Viewer gives javascript error inside ASP.Net pageGoogle Docs Viewer 在 ASP.Net 页面中给出了 javascript 错误
【发布时间】:2012-02-04 02:16:38
【问题描述】:

我正在尝试在我的页面中嵌入谷歌文档查看器。 下面是 test.aspx 代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Web_Application.test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>

    <iframe id="documentLoader" src="https://docs.google.com/viewer?embedded=true&url=http://view.samurajdata.se/license.pdf"
 style="width:100%; height:800px;">
 </iframe>
</body>
</html>

这是我的 test.aspx.cs

namespace Web_Application
{
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

我收到诸如

之类的错误
'Line: 409
Error: Unable to get value of the property 'k': object is null or undefined'

'Line: 458
Error: Unable to get value of the property 'a': object is null or undefined'

来自 google doc viewer 在线 javascript 资源...

所以我将脚本嵌入到标题中并且它起作用了。但问题是,如果我在用户控件或从母版页继承的页面中执行此操作,我会再次遇到这些错误。

我该如何解决这个问题?

谢谢。

【问题讨论】:

  • 如果您自己找到了解决此问题的方法,请使用您自己的答案更新此问题并将其标记为已接受。这也将提高您的低接受率。

标签: javascript asp.net iframe master-pages google-docs


【解决方案1】:

尝试这个独立于任何浏览器或版本的 iframe 脚本,这将起作用....

<iframe id="documentLoader" src="https://docs.google.com/viewer?url=http://view.samurajdata.se/license.pdf&chrome=true" style="width: 100%; height: 800px;">
</iframe>

如果有效,请标记是! :)

【讨论】:

  • 不幸的是它没有。我只是得到更多的java脚本错误。我需要寻找在 ASP.NET 上明确尝试过的人。
  • 你有没有在浏览器中输入过那个网址?你有什么错误吗
【解决方案2】:
<iframe id="documentLoader"
        src="https://docs.google.com/viewer?url=http//view.samurajdata.se/license.pdf&embedded=true"
        style="width:100%; height:800px;">

【讨论】:

猜你喜欢
  • 2020-12-05
  • 1970-01-01
  • 1970-01-01
  • 2017-03-16
  • 1970-01-01
  • 1970-01-01
  • 2019-03-20
  • 1970-01-01
  • 2015-07-10
相关资源
最近更新 更多