如果文本存在,请重新加载页面

我正在尝试在页面上搜索文本,如果找到文本,请重新加载页面。

These are the droids I'm looking for

这样做:

 if($('*:contains("These are the droids I\'m looking for")').length > 0) { document.href.location = document.href.location; // refresh the page } 

我会说:

 $("p.textmedium").each(function() { if ($(this).html == "These are the droids I'm looking for") window.location.reload(); }); 

用户jquery的javascript:

 

These are the droids I'm looking for