单击“提交”按钮后如何创建打开网页的在线表单

时间:2013-01-24 17:41:34

标签: php javascript html iframe online-forms

我想制作一个表格,我可以输入一个域名,然后点击提交按钮,并将域名合并到Google,Bing,Yahoo等地方的搜索结果网址中。点击提交后按钮我希望使用iframe将结果显示在页面底部。

编辑:我希望使用iframe将结果显示在页面底部,而不是打开新标签。这可能吗?以下是目前为止更新的代码:

<!DOCTYPE html>
<html>
<head>
<title>Domain Checker</title>
<meta name="description" content="Get useful information about a domain name." />
</head>
<body>

<h1>Domain Checker</h1>
<p>Use the domain checker to get useful information about a domain name. Type the domain name you want to check and hit enter.</p>

<script type='text/javascript'>
function openWindow(url)
{
  var domain2 = document.getElementById('domain2').value;
  window.open(url + domain2);
}
</script>

<form method='post'>
<label>Domain</label><input type='text' name='domain2' id='domain2'>
 <select name="select" onChange="openWindow(this.options[this.selectedIndex].value)">
  <option>Choose Below</option>
  <option value="http://www.dmoz.org/search?q=">DMOZ</option>
  <option value="https://flippa.com/valuation/">Flippa</option>
  <option value="http://web.archive.org/web/*/">WayBack</option>
  <option value="http://www.alexa.com/siteinfo/">Alexa</option>
  <option value="https://www.google.com/search?&q=site:">Google Index</option>
  <option value="https://www.google.com/search?&q=link:">Google Backlinks</option>
  <option value="http://search.yahoo.com/search?p=site:">Yahoo Index</option>
  <option value="http://search.yahoo.com/search?p=link:">Yahoo Backlinks</option>
  <option value="http://www.bing.com/search?q=site:">Bing Index</option>
  <option value="http://www.bing.com/search?q=site:">Bing Backlinks</option>
  <option value="http://whois.domaintools.com/">Whois Info</option>
 </select>
 </form>
<hr>
<p>Results show here in iframe.</p>
</body>
</html>

2 个答案:

答案 0 :(得分:2)

<script type='text/javascript'>
function openWindows(domain)
{
    if (domain) {
        window.open('http://www.dmoz.org/search?q=' + domain);
        window.open('https://flippa.com/valuation/' + domain);
        window.open('http://web.archive.org/web/*/' + domain);
        window.open('http://www.alexa.com/search?q=' + domain);
        window.open('https://www.google.com/search?&q=site:' + domain);
    }
}
</script>
<form action='your_form_processor.html' method='post' onsubmit="openWindows(document.getElementById('domain').value)">
<label>Domain</label><input type='text' name='domain' id='domain'>
</form>

答案 1 :(得分:1)

对于评论中的其他问题。

<script type='text/javascript'>
function openWindow(url)
{
  var domain = document.getElementById('domain').value;
  //window.open(url + domain);
  document.getElementById('frame').src=url+domain;
}
</script>

<form method='post'>
<label>Domain</label><input type='text' name='domain' id='domain'>
 <select name="select" onChange="openWindow(this.options[this.selectedIndex].value)">
  <option value="http://www.dmoz.org/search?q=">DMOZ</option>
  <option value="https://flippa.com/valuation/">Flippa</option>
  <option value="http://web.archive.org/web/*/">WayBack</option>
  <option value="http://www.alexa.com/search?q=">Alexa</option>
  <option value="https://www.google.com/search?&q=site:">Google</option>
 </select>
 </form>

 <iframe id="frame">Your browser does not support iframes.</iframe>