如何显示在html页面上,从API获取的数据,? [英] How to display, fetched data from API, in the html page?
问题描述
我有一个HTML页面。在这里,我使用雅虎的API TabView的。这就是:
I have an html page. Here, I am using tabview of Yahoo API. That is :
<div id="demo" class="yui-navset">
<ul class="yui-nav">
<li class="selected"><a href="#tab1" onclick="TopStories()"><em>Top Stories</em></a></li>
<li><a href="#tab2" onclick="FinanceNews()"><em>Finance</em></a></li>
<li><a href="#tab3" onclick="SportsNews()"><em>Sports</em></a></li>
</ul>
<div class="yui-content">
<div><p>Top Stories</p></div>
<div><p>Finance</p></div>
<div><p>Sports</p></div>
</div>
</div>
在onClickEvent使用的功能,从获取谷歌新闻资料>
In the onClickEvent the functions used, fetch data from Google NEWS>
function TopStories(){
location.href="http://www.google.com/news/search?aq=f&pz=1&cf=all&ned=in&hl=en&q=TopStories";
}
function FinanceNews(){
location.href="http://www.google.com/news/search?aq=f&pz=1&cf=all&ned=in&hl=en&q=Finance";
}
function SportsNews(){
location.href="http://www.google.com/news/search?aq=f&pz=1&cf=all&ned=in&hl=en&q=Sports";
}
但输出将被导航到新闻页面。但是,我想显示他们作为标签内容。
But the Output is navigation to NEWS page. But, I want to display them as Tab Content.
我应该怎么办?
推荐答案
您可以使用iframe为此..见下面的例子,,
You can use iframe for this purpose .. see below example ,,
使用jQuery的标签,它总是创建一个div您的结果显示。你只有用打开你的页面上的外部链接的方式。
Using Jquery tab, its always create a div where your result display. You have only way to open external link on your page using .
<li><a href=ReturnIfram()><span>Google</span></a></li>
的href获得包含ifram像
href get a string which contain ifram like
public string ReturnIfram()
{
return "<iframe src="http://google.fr"></iframe>"
}
以上尝试在JavaScript中见下面的例子
try above in javascript see below example
<html>
<head>
<script language="JavaScript" type="text/javascript">
function makeFrame() {
ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", "http://developerfusion.com/");
ifrm.style.width = 640+"px";
ifrm.style.height = 480+"px";
document.body.appendChild(ifrm);
}
</script>
</head>
<body>
<p><a href="#" onMouseDown="makeFrame()">GO! </a></p>
</body>
</html>
这篇关于如何显示在html页面上,从API获取的数据,?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!