函数调用在我的页面中不起作用 [英] Function calls not working in my page

查看:65
本文介绍了函数调用在我的页面中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从字体的API 。我在JSBIN中运行的是我的工作http://jsbin.com/ocutuk/18/



但是当我在html中制作我的代码副本时页面甚至没有加载页面中的字体名称。我试图让它发挥作用,但它仍处于死胡同。这是我的HTML代码

I made an select menu that works with the google-font-Api from Font-Api. I made to function in JSBIN here is my work http://jsbin.com/ocutuk/18/

But when i made the copy of my code in a html page its not even loading the font names in page. i tried to make it work but still it is in dead end. This is my html code

<html>
     <head>
      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script>
      <meta charset=utf-8 />
      <title>FONT API</title>
      <script>
        function SetFonts(fonts) { 
        for (var i = 0; i < fonts.items.length; i++) {      

        $('#styleFont')

         .append($("<option></option>")
         .attr("value", fonts.items[i].family)
         .text(fonts.items[i].family));
        }    
      }

      var script = document.createElement('script');
      script.src = 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyB8Ua6XIfe-gqbkE8P3XL4spd0x8Ft7eWo&callback=SetFonts';
      document.body.appendChild(script);

      WebFontConfig = {
    google: { families: ['ABeeZee', 'Abel', 'Abril Fatface', 'Aclonica', 'Acme', 'Actor', 'Adamina', 'Advent Pro', 'Aguafina Script', 'Akronim', 'Aladin', 'Aldrich', 'Alegreya', 'Alegreya SC', 'Alex Brush', 'Alfa Slab One', 'Alice', 'Alike', 'Alike Angular', 'Allan', 'Allerta', 'Allerta Stencil', 'Allura', 'Almendra', 'Almendra Display', 'Almendra SC', 'Amarante', 'Amaranth', 'Amatic SC', 'Amethysta', 'Anaheim', 'Andada', 'Andika']}
    };
    (function() {
    var wf = document.createElement('script');
    wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
      '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
    wf.type = 'text/javascript';
    wf.async = 'true';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(wf, s);
    })();

     $("#styleFont").change(function (){
       var id =$('#styleFont option' +':selected').val();  
                                $("#custom_text").css('font-family',id);   
       });

      </script>
      
          #custom_text {
	  font-family: Arial;
	  resize: none;
	  margin-top: 20px;
	  width: 500px;
         }
          #styleFont {
	  width: 100px;
         }
        
        </head>
        <body>
        <select id="styleFont">
        </select>
        <textarea id="custom_text"></textarea>
        </body>
        </html>





如何让它发挥作用。我在这里犯的错误是什么。

我尝试让所有字体在选择菜单中工作,它只加载165种字体。如何添加



How can i make it work. Whats the mistake i am making here.
and i tried to make all fonts to work in select menu it only load 165 fonts. How can i add it

推荐答案

('#styleFont')

。append(
('#styleFont') .append(


(< option > < / option >
.attr( value,fonts.items [i] .family)
.text(fonts.items [i] .family));
}
}

var script = document.createElement('script');
script.src ='https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyB8Ua6XIfe-gqbkE8P3XL4spd0x8Ft7eWo&callback=SetFonts';
document.body.appendChild(script);

WebFontConfig = {
google:{families:['ABeeZee','Abel','Abril Fatface','Aclonica','Acme','Actor','Adamina', 'Advent Pro','Aguafina Script','Akronim','Aladin','Aldrich','Alegreya','Alegreya SC','Alex Brush','Alfa Slab One','Alice','Alike', 'Alike Angular','Allan','Allerta','Allerta Stencil','Allura','Almendra','Almendra Display','Almendra SC','Amarante','Amaranth','Amatic SC',' Amethysta','Anaheim','Andada','Andika']}
};
(function(){
var wf = document.createElement('script');
wf.src =('https:'== document.location.protocol?'https': 'http')+
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type ='text / javascript';
wf.async ='true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf,s);
})() ;
("<option></option>") .attr("value", fonts.items[i].family) .text(fonts.items[i].family)); } } var script = document.createElement('script'); script.src = 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyB8Ua6XIfe-gqbkE8P3XL4spd0x8Ft7eWo&callback=SetFonts'; document.body.appendChild(script); WebFontConfig = { google: { families: ['ABeeZee', 'Abel', 'Abril Fatface', 'Aclonica', 'Acme', 'Actor', 'Adamina', 'Advent Pro', 'Aguafina Script', 'Akronim', 'Aladin', 'Aldrich', 'Alegreya', 'Alegreya SC', 'Alex Brush', 'Alfa Slab One', 'Alice', 'Alike', 'Alike Angular', 'Allan', 'Allerta', 'Allerta Stencil', 'Allura', 'Almendra', 'Almendra Display', 'Almendra SC', 'Amarante', 'Amaranth', 'Amatic SC', 'Amethysta', 'Anaheim', 'Andada', 'Andika']} }; (function() { var wf = document.createElement('script'); wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; wf.type = 'text/javascript'; wf.async = 'true'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wf, s); })();


(#styleFont)。change(function(){
var id =
("#styleFont").change(function (){ var id =


这篇关于函数调用在我的页面中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆