当用户 h住某些文本/关键词时,我如何展示工具? 这份案文从数据库中直接检索,因此我无法将这些关键词上的任何间隔或批号或所有权信息添加。 是否有办法自动为该页所含某些词制定工具?
让我知道,在如何解决这一问题方面是否有任何很好的指导。
当用户 h住某些文本/关键词时,我如何展示工具? 这份案文从数据库中直接检索,因此我无法将这些关键词上的任何间隔或批号或所有权信息添加。 是否有办法自动为该页所含某些词制定工具?
让我知道,在如何解决这一问题方面是否有任何很好的指导。
// Create tooltips dictionary
$tooltips = Array("Word1"=>"This word is word number 1",
"Word2"=>"This word is word number 2");
$content = "Here are Word1 and Word2";
foreach ($tooltips as $word=>$tip){
$content = preg_replace("/(".$word.")/", "<span title= ".$tip." >$1</span>", $content);
}
echo $content;
此前我不得不这样做。 实际上,我在这里回答了一个类似的问题:。 (在我旁搜寻时)。
在此,我用来做动态工具:
// keyword : tooltip
keywords = {
hello world : a common first example program ,
goodbye cruel world : the opposite of hello world
};
function insertTooltips (domNode) {
if (domNode.nodeType === Node.ELEMENT_NODE) { // We only want to scan html elements
var children = domNode.childNodes;
for (var i=0;i<children.length;i++) {
var child = children[i];
// Filter out unwanted nodes to speed up processing.
// For example, you can ignore SCRIPT nodes etc.
if (
child.nodeName != span ||
child.className != tooltip_span
) {
insertTooltips(child); // Recurse!
}
}
}
else if (domNode.nodeType === Node.TEXT_NODE) { // Process text nodes
var text = domNode.nodeValue;
// This is another place where it might be prudent to add filters
for (var i in keywords) {
if (keywords.hasOwnProperty(i)) {
var match = text.indexOf(i); // you may use search instead
if (match != -1) {
// This is how you wrap the keyword in a span:
// create a span:
var span = document.createElement( SPAN );
// split text into 3 parts: before, mid and after
var mid = domNode.splitText(match);
mid.splitText(i.length);
// then assign mid part to span
mid.parentNode.insertBefore(span,mid);
mid.parentNode.removeChild(mid);
span.appendChild(mid);
// now we can assign a mouseover event handler to the span
span.onmouseover = function(){
showToolTip(keywords[i]);
}
// give the span a class name to prevent accidental
// recursion into it:
span.className = tooltip_span ;
}
}
}
}
}
淋浴功能的实施留给读者。
基本的想法是利用OMM的操纵,以动态方式搜索和总结跨度的关键词,然后把 mo(或烟lick,直至你)的手推到这个时代,以显示工具。 在我的网站上,关键词/tooltip hash/object来自从数据库中提取的数据。
这样做比试图利用reg子进行更强,因为它防止了用阶级名称、背心和文字标签等关键词的意外处理。
实际上,你可以利用时间或一切。
你们有两个选择,第一个选择是在首页要求时装上工具内容的显示器:一是零碎或横跨,再一次用中转活动显示。
第二项选择是提出亚克斯请求。
http://www.smapingmagazine.com/2007/06/12/tooltips-scripts-ajax-javascript-cs-dhtml/“rel=“nofollow noreferer” http://www.smapingmagazine.com/2007/06/12/tooltips-scripts-ajax-javascript-cs-dhtml/。
I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
我把我的用心从使用QQL转向MySQL。 它与凯科特合作,现在不工作,因为我已经改变,使用MySQL。 这里的错误信息是:
We have a restaurant table that has lat-long data for each row. We need to write a query that performs a search to find all restaurants within the provided radius e.g. 1 mile, 5 miles etc. We have ...
Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...
Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...
What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...
My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...