English 中文(简体)
在用户使用一个文本现场张贴新表格或窗口中的链接
原标题:Opening a link in new tab or window when the user posts text using a textfield
  • 时间:2011-06-07 17:48:50
  •  标签:
  • html

我有一个文本领域,该系统的用户可以张贴任何东西,甚至可以张贴超文本标签。 我的问题是,当用户把连接点或连接点放在我网站范围以外的网页上时,用户就会离开我的领域,进入另一个网站。 我不想这样做。

I want the link to be opened in a new tab or in a new window, so that the user still remains in my domain. How do I do this?

如何展示废料:

            if($row2[ html ]==0)
        echo  <div id="scrap_text"><pre> .htmlentities($row2[ scrap ]). </pre></div> ;
        else
        echo  <div id="scrap_text"><pre> .$row2[ scrap ]. </pre></div> ;
        echo  </div> ;

j是:

$(document).ready(function(){
                                    $("#scrap_text").find("a").attr("target", "_blank");  });

我没有获得必要的功能。 上面使用PHP显示的废料,均使用AJAX。 这是否是因为干重是在document.ready之后装载的?

最佳回答

利用JQuery,你可以发现<a> tags within of auser post,然后将target=”_blank" property列入。

与此类似:

$("#post").find("a").attr("target", "_blank");
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签