2012-12-11 36 views
-3

这是我的搜索代码链接我的标签上的其他网站的搜索

<div id="search"> 
    <form method="get" action="http://www.other-website.com/search"> 
     <input type="hidden" name="f" value=""> 
     <input type="text" placeholder="Temukan informasi, komunitas & produk yang kamu cari disini" accesskey="s" name="q"> 
     <input type="submit" value="Search"> 
    </form> 
</div> 

这是标记代码(仅显示文本“不链接”)

<?php 
$posttags = get_the_tags(); 
if ($posttags) { 
    foreach($posttags as $tag) { 
    echo $tag->name . ' '; 
    } 
} 
?> 

的代码可以很好的适用该网站,但我必须输入文字进行搜索。我只想把我的标签放在搜索文字上

所以我的问题是 如何让固定词(我的标签)自动放在搜索上或我必须放置标签码的地方,搜索结果是mytag链接在@ www.other-website.com/search因此用户不必输入?我想搜索其他网站上搜索我的标签

+0

我不明白你在说什么。 – transilvlad

回答

0

经过一夜尝试& errorr,我想我已经找到了,这里是代码的细节:

<?php 
$posttags = get_the_tags(); 
if ($posttags) { 
    foreach($posttags as $tag) { 
     $tag_link = 'http://xxx.orhersite.xxx'; 
     echo "<a href='$tag_link/$tag->name'>"; 
     echo "$tag->name"; 
    } 
} ?> 

,可以直接到其他网站的搜索xxx.othersite.xxx/search/my-tag 但现在其他问题表明,如果用户点击该链接,它会在同一页面打开。 我试过

echo "<a href onclick="window.open(''); 

<?php 
$posttags = get_the_tags(); 
if ($posttags) { 
    foreach($posttags as $tag) { 
     $tag_link = 'http://xxx.orhersite.xxx'; 
     echo "<a href onclick="window.open('$tag_link/$tag->name')">"; 
     echo "$tag->name"; 
    } 
} ?> 

如何打开链接到该代码使用的onClick新标签?

0

一个简单的方法走的是价值,从那里你输入搜索查询和使用onsubmit()文本框创建一个JavaScript函数 var searchkeyword=document.forms["formname"]["textboxname/id"].value; window.location("www.othersite.com/"+searchkeyword);

+0

@ ganeshrj谢谢,你如何在我的应用程序,对不起,因为我没有编码经验。 :) –

+0

请给我你的代码你做了什么。所以我可以提供建议。 –

+0

<?php $ posttags = get_the_tags(); if($ posttags){ foreach($ posttags as $ tag){ $ tag_link ='http://xxx.orhersite.xxx'; echo“”; echo“$ tag-> name”; } }?> –

相关问题