使用iframe在同一页面中显示Google搜索结果

时间:2013-05-14 04:42:41

标签: javascript html iframe google-search

我想在我的网页中显示谷歌搜索结果,但我只得到一个空白窗口。

这是我的html和javascript代码:

<!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>
<script type="text/javascript">
function Gsitesearch(curobj)
{
    var domainroot=document.frm.domain.value;
    var date=document.frm.opt.value;
    curobj.q.value="site:"+domainroot+" "+curobj.qfront.value+" "+curobj.opt.value
}
</script>
</head>
<body>
    <form action="http://www.google.com/search" id="frm" name="frm" method="get" onSubmit="Gsitesearch(this)" target="srcnm" >
        <center>
        <h2>Search Tool Kit:</h2>
        <br />
        <table cellpadding="10" cellspacing="10">
            <tr>
                <td><input name="q" type="hidden" /></td>
            </tr>
            <tr>
                <td><b>Domain Name:</b></td>
                <td><input id="domain" type="text" style="width: 180px" /></td>
            </tr>
            <tr>
                <td><b>Search Word</b></td>
                <td><input name="qfront" type="text" style="width: 180px" /></td>
                <td>
                    <select name="opt">
                        <option>1</option>
                        <option>2</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right"><input type="submit" value="Search" /></td>
            </tr>
        </table>
    </form>
    <iframe src="http://www.google.com/search" name="srcnm" style="width:600px; height:600px;"></iframe>
</body>
</html>

如何在iframe中显示google.com?

0 个答案:

没有答案