首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gRaphael脚本403 (禁止)

gRaphael脚本403 (禁止)
EN

Stack Overflow用户
提问于 2013-03-07 18:59:22
回答 1查看 501关注 0票数 0

我在我的Xampp服务器上使用相同的here代码。

我只修改了这3行脚本:

代码语言:javascript
复制
<script src="http://raphaeljs.com/raphael.js"></script>
<script src="http://g.raphaeljs.com/g.raphael.js"></script>
<script src="http://g.raphaeljs.com/g.bar.js"></script>

但当我这样做时,Chrome返回以下消息:

代码语言:javascript
复制
GET http://raphaeljs.com/raphael.js 403 (Forbidden) barchart2.html:8
Uncaught ReferenceError: Raphael is not defined g.raphael.js:7
Uncaught ReferenceError: Raphael is not defined g.bar.js:7
Uncaught ReferenceError: Raphael is not defined barchart2.html:13

在从我的服务器加载脚本时,我尝试了一些更改:

代码语言:javascript
复制
<script src="js/raphael.js"></script>
<script src="js/g.raphael.js"></script>
<script src="js/g.bar.js"></script>

但是当我这样做的时候,我会面临这个恼人的问题:

我还更改了CSS行:

代码语言:javascript
复制
<link rel="stylesheet" href="http://g.raphaeljs.com/demo.css" media="screen">
<link rel="stylesheet" href="http://g.raphaeljs.com/demo-print.css" media="print">

有没有办法解决这个问题?!

EN

回答 1

Stack Overflow用户

发布于 2013-03-07 20:36:28

这是一个工作版本,一个完整的html文件源...(使用jQuery在就绪页面上加载)

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="http://raphaeljs.com/raphael.js" ></script>
<script type="text/javascript" src="http://g.raphaeljs.com/g.raphael.js" ></script>
<script type="text/javascript" src="http://g.raphaeljs.com/g.bar.js" ></script>

</head>
<body>


<script language="javascript" type="text/javascript" defer>
$(function() {
   var r = Raphael("holder"),
                    fin = function () {
                        this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
                    },
                    fout = function () {
                        this.flag.animate({
                            opacity: 0
                        }, 300, function () {
                            this.remove();
                        });
                    },
                    fin2 = function () {
                        var y = [],
                            res = [];
                        for (var i = this.bars.length; i--;) {
                            y.push(this.bars[i].y);
                            res.push(this.bars[i].value || "0");
                        }
                        this.flag = r.popup(this.bars[0].x, Math.min.apply(Math, y), res.join(", ")).insertBefore(this);
                    },
                    fout2 = function () {
                        this.flag.animate({
                            opacity: 0
                        }, 300, function () {
                            this.remove();
                        });
                    },
                    txtattr = {
                        font: "12px sans-serif"
                    };

                r.text(160, 10, "Single Series Chart").attr(txtattr);
                r.text(480, 10, "Multiline Series Stacked Chart").attr(txtattr);
                r.text(160, 250, "Multiple Series Chart").attr(txtattr);
                r.text(480, 250, "Multiline Series Stacked Chart\nColumn Hover").attr(txtattr);

                r.barchart(10, 10, 300, 220, [
                    [55, 20, 13, 32, 5, 1, 2, 10]
                ]).hover(fin, fout);
                r.hbarchart(330, 10, 300, 220, [
                    [55, 20, 13, 32, 5, 1, 2, 10],
                    [10, 2, 1, 5, 32, 13, 20, 55]
                ], {
                    stacked: true
                }).hover(fin, fout);
                r.hbarchart(10, 250, 300, 220, [
                    [55, 20, 13, 32, 5, 1, 2, 10],
                    [10, 2, 1, 5, 32, 13, 20, 55]
                ]).hover(fin, fout);
                var c = r.barchart(330, 250, 300, 220, [
                    [55, 20, 13, 32, 5, 1, 2, 10],
                    [10, 2, 1, 5, 32, 13, 20, 55]
                ], {
                    stacked: true,
                    type: "soft"
                }).hoverColumn(fin2, fout2);
                });
</script>
<div id="holder"></div>
</body>
</html>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15269378

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档