小编bar*_*rit的帖子

为什么body onload不能用于chrome

我遇到了一个问题,我的身体onload ="constructor()"没有被运行.它在firefox中对我来说很好用,但我不明白为什么它不适用于我的chrome.这是我正在使用的代码,我创建了一个单独的文件,删除了所有内容,以便找出出错的地方:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8" />
    <title>Personality Font</title>
    <link rel="stylesheet" type="text/css" href="p1.css" />
    <script type="text/javascript" src="data.js"></script>
    <script type="text/javascript">
    //<![CDATA[


        function constructor(which)
        {
            console.log("IN CONSTRUCTOR"); //In Constructor
            var text = document.createElement('p');
            text.appendChild(document.createTextNode("BLAH"));
            document.getElementsByTagName('body')[0].appendChild(text);

        }

    //]]>
    </script>
</head>

<body onload = "constructor();">
    <h1>Personal Fonts: Find the Typeface that Matches Your Personality</h1>
    <form>

    </form>


</body>
</html>
Run Code Online (Sandbox Code Playgroud)

html javascript

3
推荐指数
1
解决办法
3656
查看次数

有没有办法在Javascript中执行子字符串,但是使用字符串字符作为您要选择的参数?

所以一个子字符串可以带两个参数,索引开始于,索引停止在这样

   var str="Hello beautiful world!";
   document.write(str.substring(3,7));
Run Code Online (Sandbox Code Playgroud)

但是有没有办法将开始点和停止点指定为要抓取的一组字符,所以不是起点是3而是我希望它是"lo"而不是终点是7我想要它是"我"所以我会抓住"美丽的窝".是否有一个Javascript函数已经服务于此目的?

html javascript

1
推荐指数
1
解决办法
114
查看次数

如何在Flash ActionScript 3.0中使用JSON API

我想知道是否有人可以解释或指出我如何实现在ActionScript 3.0中使用JSON的API.我特别想知道的是如何获取具体信息.以下是我在XML中的使用方法,但我不知道如何在JSON中执行类似于获取XML标记的等效内容.例如,使用twitter API,我想获取文本https://dev.twitter.com/docs/api/1/get/search

        -----------XML Example:
        //create a new XML object with the XML
        xml = new XML(e.target.data);

        //This gives us an XMLList (an array) of <item> tags
        var all_items:XMLList = xml.channel.item;

        //loop through the <item> tags
        for (var i:uint = 0; i < all_items.length(); i++)
        {
            //get contents of title tag
            var titleText:String = all_items[i].title.text();

            //get contents of description tag
            var descriptionText:String = all_items[i].description.text();

            //get contents of link tag
            var linkText:String = all_items[i].link.text();

            //get contents of pubDate tag
            var …
Run Code Online (Sandbox Code Playgroud)

flash json actionscript-3

0
推荐指数
1
解决办法
3701
查看次数

标签 统计

html ×2

javascript ×2

actionscript-3 ×1

flash ×1

json ×1